/* ========================================
   VARIABLES
   ======================================== */

:root {
    --sidebar-width: 80px;
    --bg-color: #f3f4f6;
    --sidebar-bg: #ffffff;
    --icon-color: #6b7280;
    --icon-hover-bg: #f3f4f6;
    --icon-active-color: #111827;
    --accent-color: #3b82f6;
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    --transition: all 0.2s ease;
}

[data-bs-theme="dark"] {
    --bg-color: #111827;
    --sidebar-bg: #1f2937;
    --icon-color: #9ca3af;
    --icon-hover-bg: #374151;
    --icon-active-color: #ffffff;
}


/* ========================================
   BASE
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    touch-action: none; /* Empêche le bounce sur iOS */
}


/* ========================================
   SIDEBAR
   ======================================== */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--icon-hover-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
    z-index: 1000;
}

.sidebar-brand {
    margin-bottom: 2rem;
    width: 40px;
    height: 40px;
}

.sidebar-brand img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    align-items: center;
}

.nav-btn {
    width: 48px;
    height: 48px;
    border: none;
    background: transparent;
    border-radius: 12px;
    color: var(--icon-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent; /* Supprime le flash bleu sur mobile */
}

.nav-btn:hover, .nav-btn.active {
    background-color: var(--icon-hover-bg);
    color: var(--icon-active-color);
}

.nav-btn i {
    font-size: 1.3rem;
}


/* ========================================
   MAIN CONTENT
   ======================================== */

.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}


/* ========================================
   HEADER
   ======================================== */

.top-header {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-container {
    position: relative;
}

.user-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: var(--sidebar-bg);
    border-radius: 8px;
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-lg);
    -webkit-tap-highlight-color: transparent;
}

.user-avatar {
    width: 28px;
    height: 28px;
    background: var(--icon-active-color);
    color: var(--sidebar-bg);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
}

.chevron {
    font-size: 0.7rem;
    color: var(--icon-color);
    transition: transform 0.3s ease;
}

.user-container.expanded .chevron {
    transform: rotate(180deg);
}

.user-drawer {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--sidebar-bg);
    border-radius: 8px;
    min-width: 140px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.user-container.expanded .user-drawer {
    max-height: 120px;
    opacity: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    color: var(--icon-active-color);
    text-decoration: none;
    font-size: 0.8rem;
}

.menu-item:hover {
    background: var(--icon-hover-bg);
}

.menu-item.logout {
    color: #dc2626;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--sidebar-bg);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-color);
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
    color: var(--icon-active-color);
}


/* ========================================
   TOOLBAR FLOTTANTE
   ======================================== */

.floating-toolbar {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--sidebar-bg);
    border-radius: 16px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.floating-toolbar.hidden {
    opacity: 0;
    transform: translateY(-50%) translateX(-20px);
    pointer-events: none;
}

.tool-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    border-radius: 12px;
    color: var(--icon-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.tool-btn:hover {
    background: var(--icon-hover-bg);
    color: var(--icon-active-color);
}

.tool-btn.active {
    background: var(--accent-color);
    color: white;
}

.tool-btn i {
    font-size: 1.2rem;
}

.toolbar-divider {
    height: 1px;
    background: var(--icon-hover-bg);
    margin: 0.25rem 0;
}

.color-btn {
    position: relative;
}

.color-indicator {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #000;
    border: 2px solid var(--sidebar-bg);
}

/* Input couleur caché */
#colorPicker {
    position: fixed;
    visibility: hidden;
    pointer-events: none;
}


/* ========================================
   CANVAS - 100% SANS BORDURE
   ======================================== */

.canvas-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #ffffff;
    touch-action: none; /* CRUCIAL pour mobile */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

[data-bs-theme="dark"] .canvas-area {
    background: #1f2937;
}

#whiteboard {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: default;
    touch-action: none;
}


/* ========================================
   POST-IT
   ======================================== */

.sticky-note {
    position: absolute;
    width: 220px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10; /* Au-dessus des connexions */
    user-select: none;
    touch-action: none; /* Empêche le scroll quand on drag */
}

.note-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.8rem;
    background: #f3f4f6;
    border-radius: 12px 12px 0 0;
    cursor: grab;
    border-bottom: 1px solid #e5e7eb;
    touch-action: none;
}

.note-header:active {
    cursor: grabbing;
}

.note-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ef4444;
}

.note-actions {
    display: flex;
    gap: 0.25rem;
}

.note-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-color);
    cursor: pointer;
    font-size: 0.8rem;
    opacity: 0;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.sticky-note:hover .note-btn,
.sticky-note:active .note-btn {
    opacity: 1;
}

.note-btn:hover {
    background: var(--icon-hover-bg);
    color: var(--icon-active-color);
}

.note-content {
    min-height: 120px;
    padding: 0.8rem;
    outline: none;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--icon-active-color);
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
}

.note-content:empty:before {
    content: 'Écrivez quelque chose...';
    color: var(--icon-color);
    font-style: italic;
}


/* ========================================
   TEXTE DIRECT
   ======================================== */

.direct-text {
    position: absolute;
    padding: 4px 8px;
    font-size: 16px;
    color: var(--icon-active-color);
    outline: none;
    cursor: text;
    min-width: 50px;
    z-index: 55;
    user-select: text;
    -webkit-user-select: text;
}

.direct-text:focus {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
}


/* ========================================
   CONNEXIONS
   ======================================== */

.connection-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1; /* Derrière les notes */
}

.connection-svg line {
    fill: none;
    stroke: #374151;
    stroke-width: 3;
    stroke-linecap: round;
}


/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.2rem;
    height: 60px;           /* ou ta hauteur actuelle */
    gap: 1rem;
}

.datetime-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-size: 0.85rem;
    color: var(--text-secondary);     /* ou ta couleur */
    min-width: 110px;
    text-align: left;
}

.current-date {
    font-weight: 500;
    opacity: 0.9;
}

.current-time {
    font-weight: 400;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

.header-spacer {
    flex: 1;   /* pousse les éléments de droite à l'extrême droite */
}