/* ----------------------------------------------------
   ARBORIZ - DESIGN SYSTEM & STYLES (Vanilla CSS)
   Thème : Catppuccin Mocha (Sombre & Énergétiquement Sobre)
   ---------------------------------------------------- */

:root {
    /* Couleurs Thème Sombre (Catppuccin Mocha) */
    --color-bg-base: #1e1e2e;
    --color-bg-mantle: #181825;
    --color-bg-crust: #11111b;
    --color-bg-surface: #313244;
    --color-bg-overlay: #45475a;
    
    --color-text: #cdd6f4;
    --color-subtext: #a6adc8;
    --color-muted: #6c7086;
    
    --color-primary: #cba6f7;     /* Mauve */
    --color-primary-hover: #f5c2e7;
    --color-secondary: #89b4fa;   /* Bleu */
    --color-accent: #a6e3a1;      /* Vert */
    --color-warn: #f9e2af;        /* Jaune */
    --color-danger: #f38ba8;      /* Rouge */
    
    /* Effets de Verre (Glassmorphism) */
    --glass-bg: rgba(24, 24, 37, 0.7);
    --glass-border: rgba(203, 166, 247, 0.15);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --glass-blur: blur(12px);

    /* Fonts & Spacing */
    --font-primary: 'Inter', system-ui, -apple-system, sans-serif;
    --font-display: 'Outfit', var(--font-primary);
    --border-radius-sm: 6px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* ----------------------------------------------------
   RESET & BASE STYLES
   ---------------------------------------------------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--color-bg-base);
    color: var(--color-text);
    font-family: var(--font-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ----------------------------------------------------
   LAYOUT STRUCTURE
   ---------------------------------------------------- */
.app-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    position: relative;
}

/* ----------------------------------------------------
   SIDEBAR (DASHBOARD)
   ---------------------------------------------------- */
.sidebar {
    width: 320px;
    height: 100%;
    background-color: var(--color-bg-crust);
    border-right: 1px solid var(--color-bg-surface);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-normal);
    position: relative;
}

.sidebar.closed {
    transform: translateX(-100%);
    position: absolute;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--color-bg-surface);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo h1 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-section {
    padding: 20px;
    border-bottom: 1px solid var(--color-bg-surface);
}

.sidebar-section h3 {
    font-family: var(--font-display);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-subtext);
    margin-bottom: 15px;
}

.sidebar-section h4 {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-title-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-title-container h3 {
    margin-bottom: 0;
}

/* Profiles & Auth Section */
.profile-section {
    background-color: var(--color-bg-mantle);
}

.logged-out-view p {
    font-size: 0.8rem;
    color: var(--color-subtext);
    margin-bottom: 12px;
    line-height: 1.4;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.user-avatar {
    font-size: 1.8rem;
    background: var(--color-bg-surface);
    padding: 8px;
    border-radius: 50%;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-email {
    font-size: 0.85rem;
    font-weight: 500;
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sync-status {
    font-size: 0.75rem;
    color: var(--color-muted);
}

.sync-status.synced {
    color: var(--color-accent);
}

.sync-status.syncing {
    color: var(--color-warn);
}

.profile-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Map List */
.maps-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
}

.maps-list::-webkit-scrollbar {
    width: 4px;
}
.maps-list::-webkit-scrollbar-thumb {
    background-color: var(--color-bg-surface);
    border-radius: 2px;
}

.maps-list li {
    padding: 10px 12px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background var(--transition-fast);
    border: 1px solid transparent;
}

.maps-list li:hover {
    background-color: var(--color-bg-mantle);
}

.maps-list li.active {
    background-color: rgba(203, 166, 247, 0.1);
    border-color: rgba(203, 166, 247, 0.25);
    color: var(--color-primary);
    font-weight: 500;
}

.map-item-title {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 8px;
}

.map-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.maps-list li:hover .map-item-actions {
    opacity: 1;
}

.sidebar-footer {
    margin-top: auto;
    padding: 15px 20px;
    border-top: 1px solid var(--color-bg-surface);
    font-size: 0.75rem;
    color: var(--color-muted);
    text-align: center;
}

/* Toggle buttons */
.sidebar-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 99;
}

.sidebar.closed ~ .sidebar-toggle {
    display: flex;
}

.sidebar ~ .sidebar-toggle {
    display: none;
}

/* ----------------------------------------------------
   CANVAS CONTAINER & VIEWPORT
   ---------------------------------------------------- */
.canvas-wrapper {
    flex-grow: 1;
    height: 100%;
    position: relative;
    overflow: hidden;
    outline: none;
}

.canvas-container {
    width: 100%;
    height: 100%;
    position: relative;
    cursor: grab;
    user-select: none;
    background-color: var(--color-bg-base);
}

.canvas-container:active {
    cursor: grabbing;
}

.canvas-viewport {
    position: absolute;
    width: 10000px;
    height: 10000px;
    left: -5000px;
    top: -5000px;
    transform-origin: center center;
    pointer-events: none;
}

.canvas-viewport * {
    pointer-events: auto;
}

/* Connections Layer (SVG) */
.canvas-connections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.canvas-connections path {
    fill: none;
    stroke-linecap: round;
    transition: stroke var(--transition-fast), stroke-width var(--transition-fast);
}

.connection-line {
    stroke: var(--color-bg-overlay);
    stroke-width: 2.5px;
}

.connection-line.active {
    stroke: var(--color-primary);
    stroke-width: 3.5px;
    filter: drop-shadow(0 0 4px var(--color-primary));
}

.connection-line.selected {
    stroke: var(--color-secondary);
    stroke-dasharray: 6, 4;
    stroke-width: 3.5px;
}

.connection-label {
    fill: var(--color-subtext);
    font-size: 11px;
    font-family: var(--font-primary);
    font-weight: 500;
}

/* Nodes Layer */
.canvas-nodes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* ----------------------------------------------------
   RICH BUBBLES / BUBBLE COMPONENT
   ---------------------------------------------------- */
.mindmap-node {
    position: absolute;
    width: 280px;
    min-height: 80px;
    background-color: var(--color-bg-mantle);
    border: 2px solid var(--color-bg-surface);
    border-radius: var(--border-radius-md);
    padding: 14px;
    color: var(--color-text);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    cursor: pointer;
    user-select: text;
    pointer-events: auto;
    touch-action: none; /* Empêche le défilement de page natif quand on touche la bulle */
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform 0.1s ease-out;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Hover and selection states */
.mindmap-node:hover {
    border-color: var(--color-muted);
}

.mindmap-node.selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(203, 166, 247, 0.25), 0 8px 24px rgba(0,0,0,0.4);
}

.mindmap-node.dragging {
    opacity: 0.95;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    transform: scale(1.02) !important;
    z-index: 100 !important;
}

/* Node Handle for dragging (Header Grip Bar) */
.node-drag-handle {
    width: 100%;
    height: 22px;
    background-color: rgba(17, 17, 27, 0.45);
    border-radius: 10px 10px 0 0;
    margin: -14px -14px 6px -14px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    color: var(--color-muted);
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.node-drag-handle:hover {
    background-color: rgba(17, 17, 27, 0.7);
    color: var(--color-primary);
}

.mindmap-node:hover .node-drag-handle {
    color: var(--color-subtext);
}

/* Node Content Area */
.node-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-wrap: break-word;
}

/* Editor Blocks inside Nodes */
.node-block {
    position: relative;
    border-radius: var(--border-radius-sm);
    transition: background-color var(--transition-fast);
}

/* Text Block */
.block-text {
    font-size: 0.9rem;
    line-height: 1.4;
    outline: none;
    padding: 4px;
}

.block-text h1, .block-text h2, .block-text h3 {
    font-family: var(--font-display);
    margin-bottom: 6px;
    font-weight: 600;
}

.block-text h1 { font-size: 1.25rem; }
.block-text h2 { font-size: 1.1rem; }
.block-text h3 { font-size: 0.95rem; }

.block-text p {
    margin-bottom: 4px;
}

.block-text strong {
    color: var(--color-primary);
}

.block-text em {
    color: var(--color-secondary);
}

.block-text mark {
    background-color: rgba(249, 226, 175, 0.3);
    color: var(--color-warn);
    padding: 0 4px;
    border-radius: 3px;
}

/* Checklist Block */
.block-checklist {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.85rem;
}

.checklist-item input[type="checkbox"] {
    margin-top: 3px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.checklist-item span {
    flex-grow: 1;
    outline: none;
}

.checklist-item.checked span {
    text-decoration: line-through;
    color: var(--color-muted);
}

/* Table Block */
.block-table-wrapper {
    overflow-x: auto;
    max-width: 100%;
    margin-top: 4px;
}

.block-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.block-table th, .block-table td {
    border: 1px solid var(--color-bg-surface);
    padding: 4px 6px;
    text-align: left;
    outline: none;
}

.block-table th {
    background-color: var(--color-bg-surface);
    font-weight: 600;
}

/* Image Block */
.block-image {
    position: relative;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    max-height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--color-bg-crust);
}

.block-image img {
    max-width: 100%;
    max-height: 150px;
    object-fit: cover;
}

/* Node Quick Action buttons (appears on select/hover) */
.node-actions {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    background-color: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur);
    padding: 6px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--glass-shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    z-index: 10;
}

.mindmap-node.selected .node-actions,
.mindmap-node:hover .node-actions {
    opacity: 1;
    pointer-events: auto;
}

.node-action-btn {
    border: none;
    background: none;
    color: var(--color-text);
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.node-action-btn:hover {
    background-color: var(--color-bg-surface);
    color: var(--color-primary);
}

.node-action-btn-danger:hover {
    color: var(--color-danger);
}

/* Color Picker Dropdown */
.color-picker-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    display: flex;
    gap: 8px;
    background-color: var(--color-bg-surface);
    padding: 8px;
    border-radius: var(--border-radius-md);
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--color-bg-overlay);
    z-index: 20;
}

.color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 1.5px solid rgba(255,255,255,0.1);
    transition: transform var(--transition-fast);
}

.color-dot:hover {
    transform: scale(1.2);
}

/* ----------------------------------------------------
   FLOATING CANVAS CONTROLS & HEADER
   ---------------------------------------------------- */
.canvas-controls {
    position: absolute;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur);
    padding: 8px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--glass-shadow);
    z-index: 10;
}

.btn-control {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: transparent;
    color: var(--color-text);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.btn-control:hover {
    background-color: var(--color-bg-surface);
    color: var(--color-primary);
}

.btn-control-primary {
    width: auto;
    padding: 0 16px;
    border-radius: 20px;
    background-color: rgba(203, 166, 247, 0.15);
    border: 1px solid rgba(203, 166, 247, 0.3);
    color: var(--color-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

.btn-control-primary:hover {
    background-color: var(--color-primary);
    color: var(--color-bg-crust);
}

.control-divider {
    width: 1px;
    height: 24px;
    background-color: var(--color-bg-surface);
    margin: 0 4px;
}

/* Map Header (Top Center) */
.map-header {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur);
    padding: 8px 16px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--glass-shadow);
    z-index: 10;
    display: flex;
    align-items: center;
}

.map-title-input {
    background: none;
    border: none;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    outline: none;
    text-align: center;
    width: 250px;
    transition: border-bottom var(--transition-fast);
}

.map-title-input:focus {
    border-bottom: 2px solid var(--color-primary);
}

/* ----------------------------------------------------
   BUTTONS & FORM ELEMENTS
   ---------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-primary);
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
    border-radius: var(--border-radius-sm);
}

.btn-xs {
    padding: 6px 10px;
    font-size: 0.75rem;
    border-radius: 4px;
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-bg-crust);
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
}

.btn-secondary {
    background-color: var(--color-bg-surface);
    border-color: var(--color-bg-overlay);
    color: var(--color-text);
}

.btn-secondary:hover {
    background-color: var(--color-bg-overlay);
}

.btn-danger-link {
    background: none;
    border: none;
    color: var(--color-danger);
}

.btn-danger-link:hover {
    text-decoration: underline;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--color-subtext);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: var(--border-radius-sm);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-icon:hover {
    background-color: var(--color-bg-surface);
    color: var(--color-text);
}

/* Forms */
.form-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.8rem;
    color: var(--color-subtext);
}

input[type="email"],
input[type="password"],
input[type="text"],
select {
    padding: 10px 12px;
    border-radius: var(--border-radius-sm);
    background-color: var(--color-bg-surface);
    border: 1px solid var(--color-bg-overlay);
    color: var(--color-text);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus,
select:focus {
    border-color: var(--color-primary);
}

/* ----------------------------------------------------
   MODALS
   ---------------------------------------------------- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(17, 17, 27, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    transition: opacity var(--transition-fast);
}

.modal {
    background-color: var(--color-bg-mantle);
    border: 1px solid var(--color-bg-surface);
    width: 90%;
    max-width: 450px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--glass-shadow);
    overflow: hidden;
    animation: modal-enter 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-md {
    max-width: 600px;
}

@keyframes modal-enter {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--color-bg-surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-actions {
    padding: 15px 20px;
    border-top: 1px solid var(--color-bg-surface);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.auth-toggle-hint {
    margin-top: 12px;
    text-align: center;
    font-size: 0.8rem;
}

.auth-toggle-hint a {
    color: var(--color-primary);
    text-decoration: none;
}

.auth-toggle-hint a:hover {
    text-decoration: underline;
}

/* Collaborators list */
.collaborators-list {
    list-style: none;
    margin-top: 10px;
}

.collaborators-list li {
    padding: 8px 12px;
    background-color: var(--color-bg-crust);
    border-radius: var(--border-radius-sm);
    margin-bottom: 6px;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.collaborator-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.collaborator-badge.read {
    background-color: rgba(137, 180, 250, 0.15);
    color: var(--color-secondary);
}

.collaborator-badge.write {
    background-color: rgba(166, 227, 161, 0.15);
    color: var(--color-accent);
}

/* Help table */
.help-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.help-table th, .help-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--color-bg-surface);
}

.help-table th {
    font-family: var(--font-display);
    color: var(--color-subtext);
    font-weight: 600;
}

kbd {
    background-color: var(--color-bg-surface);
    border: 1px solid var(--color-bg-overlay);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: monospace;
    color: var(--color-primary);
}

/* ----------------------------------------------------
   TOAST NOTIFICATIONS
   ---------------------------------------------------- */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 300;
}

.toast {
    background-color: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur);
    padding: 12px 18px;
    border-radius: var(--border-radius-md);
    box-shadow: var(--glass-shadow);
    color: var(--color-text);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toast-enter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 320px;
}

@keyframes toast-enter {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.toast.success { border-color: rgba(166, 227, 161, 0.3); }
.toast.info { border-color: rgba(137, 180, 250, 0.3); }
.toast.warn { border-color: rgba(249, 226, 175, 0.3); }
.toast.error { border-color: rgba(243, 139, 168, 0.3); }

/* ----------------------------------------------------
   UTILITIES
   ---------------------------------------------------- */
.hidden { display: none !important; }
.w-full { width: 100% !important; }
.text-center { text-align: center; }
.cursor-pointer { cursor: pointer; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.flex-grow { flex-grow: 1; }
.grid { display: grid; }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gap-2 { gap: 8px; }
.empty-state {
    color: var(--color-muted);
    font-style: italic;
    font-size: 0.8rem;
    text-align: center;
    padding: 15px 0;
}

/* ----------------------------------------------------
   FLOATING TOP-RIGHT TOOLBAR (Account, Sync, Share)
   ---------------------------------------------------- */
.top-right-toolbar {
    position: absolute;
    top: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 99;
}

.logged-in-toolbar-view {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur);
    padding: 6px 12px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--glass-shadow);
}

.toolbar-user-badge {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-primary);
    background-color: var(--color-bg-surface);
    padding: 6px 12px;
    border-radius: 14px;
    border: 1px solid rgba(203, 166, 247, 0.2);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ----------------------------------------------------
   RICH BUBBLE ELEMENT BUTTONS STYLING
   ---------------------------------------------------- */
/* Block additions toolbar (floating below node on select) */
.editor-add-toolbar {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    gap: 6px;
    background-color: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur);
    padding: 6px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--glass-shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    z-index: 10;
    margin: 0;
    white-space: nowrap;
}

/* Display only when node is selected */
.mindmap-node.selected .editor-add-toolbar {
    opacity: 1;
    pointer-events: auto;
}

.btn-add-block {
    background: none;
    border: none;
    color: var(--color-text);
    padding: 5px 8px;
    border-radius: var(--border-radius-md);
    font-size: 0.75rem;
    font-family: var(--font-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-add-block:hover {
    background-color: var(--color-bg-surface);
    color: var(--color-primary);
}

/* Block delete button (×) */
.node-block-wrapper {
    position: relative;
}

.btn-delete-block {
    position: absolute;
    top: 2px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: none;
    background-color: rgba(17, 17, 27, 0.6);
    color: var(--color-muted);
    font-size: 11px;
    line-height: 14px;
    text-align: center;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--transition-fast);
    z-index: 5;
}

.node-block-wrapper:hover .btn-delete-block {
    opacity: 1;
}

.btn-delete-block:hover {
    background-color: var(--color-danger);
    color: var(--color-bg-crust);
}

/* Checklist add item button */
.btn-add-checklist-item {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 0.75rem;
    padding: 4px 6px;
    cursor: pointer;
    text-align: left;
    margin-top: 4px;
    font-family: var(--font-primary);
    transition: color var(--transition-fast);
    display: inline-block;
    width: fit-content;
}

.btn-add-checklist-item:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

/* Table modification buttons */
.table-edit-controls {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
}

.btn-table-control {
    background-color: var(--color-bg-surface);
    border: 1px solid var(--color-bg-overlay);
    color: var(--color-subtext);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-family: var(--font-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-table-control:hover {
    background-color: var(--color-bg-overlay);
    color: var(--color-secondary);
}

/* ----------------------------------------------------
   STARRY GRID ANIMATIONS (Effet Nuit Étoilée)
   ---------------------------------------------------- */
@keyframes star-twinkle {
    0%, 80%, 100% {
        opacity: 0.25; /* Reste sombre et discret 80% du cycle */
    }
    90% {
        opacity: 1.0;  /* Scintille brièvement à pleine intensité */
    }
}

.star {
    fill: #bac2de; /* Couleur claire très lumineuse (Subtext1) pour briller intensément */
    animation: star-twinkle 4s infinite ease-in-out;
}

/* ----------------------------------------------------
   LINKING MODE CURSORS & STYLE
   ---------------------------------------------------- */
.canvas-container.linking-mode {
    cursor: crosshair !important;
}

.canvas-container.linking-mode .mindmap-node {
    cursor: cell !important;
}

/* Style de la liaison temporaire en pointillés avec effet de défilement (marching ants) */
.connection-line.temp-line {
    stroke-width: 2.5px;
    stroke-linecap: round;
    animation: temp-line-dash 1s infinite linear;
}

@keyframes temp-line-dash {
    to {
        stroke-dashoffset: -20;
    }
}

/* ----------------------------------------------------
   RESPONSIVE DESIGN (MOBILE SCREEN ADJUSTMENTS)
   ---------------------------------------------------- */
@media (max-width: 768px) {
    /* 1. Déplacer et affiner le titre de la carte pour éviter le conflit avec le bouton de connexion */
    .map-header {
        top: 85px;
        left: 50%;
        transform: translateX(-50%);
        max-width: calc(100vw - 32px);
        padding: 6px 12px;
    }
    
    .map-title-input {
        width: 180px;
        font-size: 0.95rem;
    }

    /* 2. Ajuster les contrôles du canvas (footer) pour les petits écrans */
    .canvas-controls {
        bottom: 16px;
        right: 16px;
        left: 16px;
        justify-content: space-between;
        padding: 6px;
        gap: 6px;
    }
    
    .btn-control {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }
    
    #btn-add-node-fab {
        flex-grow: 1;
        border-radius: var(--border-radius-md);
        font-size: 0.85rem;
        padding: 0 8px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Cacher le texte long sur mobile pour compacter les boutons */
    .btn-control .btn-text {
        display: none !important;
    }

    /* Ajuster la barre d'outils haut-droite (Sync/Share/Compte) */
    .top-right-toolbar {
        top: 24px;
        right: 16px;
        gap: 6px;
    }
    
    /* Réduire la taille des badges/boutons de la toolbar pour éviter les chevauchements */
    .top-right-toolbar .btn-sm {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    .logged-in-toolbar-view {
        padding: 4px 8px;
        gap: 4px;
    }
}
