/**
 * ╔══════════════════════════════════════════════════════════════════════════════╗
 * ║         AT·OM IMMERSIVE UI — Styles du layout immersif (Phase 11)         ║
 * ║                                                                            ║
 * ║  Structure:                                                               ║
 * ║  - Docks latéraux (gauche: sphères, droite: communication)               ║
 * ║  - Workspace immersif (pages plein écran)                                ║
 * ║  - Bottom bar (exec tabs | minimap | comm tabs)                          ║
 * ║  - Nav bar type navigateur (dans le workspace)                           ║
 * ║                                                                            ║
 * ║  Paradigme: "On entre dans son espace de travail"                        ║
 * ║  Les onglets s'accumulent sans changer l'environnement de fond.          ║
 * ╚══════════════════════════════════════════════════════════════════════════════╝
 */


/* ═══════════════════════════════════════════════════════════════════════════════
   IMMERSIVE VARIABLES
   ═══════════════════════════════════════════════════════════════════════════════ */
:root {
    /* Dock dimensions */
    --dock-icon-w: 52px;
    --dock-expanded-w: 280px;

    /* Bottom bar */
    --bottombar-h: 48px;

    /* Nav bar */
    --navbar-h: 38px;

    /* Minimap */
    --minimap-size: 72px;

    /* Immersive transitions */
    --dock-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --page-transition: 0.2s ease;
}


/* ═══════════════════════════════════════════════════════════════════════════════
   DESKTOP MAIN — Container principal (docks + workspace)
   ═══════════════════════════════════════════════════════════════════════════════ */
#desktop-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}


/* ═══════════════════════════════════════════════════════════════════════════════
   DOCKS — Panneaux latéraux (gauche: sphères, droite: communication)
   ═══════════════════════════════════════════════════════════════════════════════ */
#dock-left,
#dock-right {
    position: relative;
    display: flex;
    width: var(--dock-icon-w);
    flex-shrink: 0;
    z-index: 200;
    transition: width var(--dock-transition);
    overflow: hidden;
}

#dock-left {
    border-right: 1px solid var(--border);
}

#dock-right {
    border-left: 1px solid var(--border);
}

/* Expanded state */
#dock-left.expanded,
#dock-right.expanded {
    width: var(--dock-expanded-w);
}

/* ─── Icon Strip ──────────────────────────────────────────────────────────── */
.dock-icon-strip {
    width: var(--dock-icon-w);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
    gap: 4px;
    background: var(--surface);
    overflow-y: auto;
    overflow-x: hidden;
}

.dock-icon-strip::-webkit-scrollbar {
    width: 0;
}

.dock-icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
    position: relative;
}

.dock-icon-btn:hover {
    background: var(--surface-hover);
    transform: scale(1.05);
}

.dock-icon-btn.active {
    background: var(--surface-active);
    color: var(--text-primary);
}

/* Sphere active glow */
.dock-icon-btn.active::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 0 3px 3px 0;
    background: var(--sphere-color, var(--accent));
    box-shadow: 0 0 8px var(--sphere-color, var(--accent));
}

/* Right dock active indicator on right side */
#dock-right .dock-icon-btn.active::before {
    left: auto;
    right: -4px;
    border-radius: 3px 0 0 3px;
}

/* Sphere lock state (progressive unlock) */
.dock-icon-btn.sphere-locked {
    opacity: 0.3;
    filter: grayscale(1);
}
.dock-icon-btn.sphere-locked:hover {
    opacity: 0.5;
    filter: grayscale(0.5);
}
.dock-panel-item.sphere-locked {
    opacity: 0.4;
}
.dock-panel-item.sphere-locked:hover {
    opacity: 0.6;
}
.sphere-progress {
    font-size: 0.8rem;
    color: var(--text-tertiary, rgba(255,255,255,0.3));
    text-align: center;
    padding: 4px 0;
    letter-spacing: 0.5px;
}

/* Badge on dock icon */
.dock-icon-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

.dock-icon-badge:empty,
.dock-icon-badge[data-count="0"] {
    display: none;
}

/* ─── Expanded Panel ─────────────────────────────────────────────────────── */
.dock-expanded-panel {
    flex: 1;
    min-width: 0;
    display: none;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
}

#dock-right .dock-expanded-panel {
    border-left: none;
    border-right: 1px solid var(--border);
    order: -1;  /* Panel on the left of icon strip */
}

#dock-left.expanded .dock-expanded-panel,
#dock-right.expanded .dock-expanded-panel {
    display: flex;
    animation: dockPanelSlideIn 0.25s ease;
}

@keyframes dockPanelSlideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
}

#dock-right.expanded .dock-expanded-panel {
    animation-name: dockPanelSlideInRight;
}

@keyframes dockPanelSlideInRight {
    from { opacity: 0; transform: translateX(8px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Panel header */
.dock-panel-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Panel search */
.dock-panel-search {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.dock-panel-search input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--desktop-bg);
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
}

.dock-panel-search input:focus {
    border-color: var(--accent);
}

/* Panel content items */
.dock-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.dock-panel-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background var(--t-fast);
    color: var(--text-secondary);
    font-size: 12px;
}

.dock-panel-item:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.dock-panel-item.active {
    background: var(--surface-active);
    color: var(--text-primary);
}

.dock-panel-item-icon {
    font-size: 16px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.dock-panel-item-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dock-panel-item-badge {
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.dock-panel-section {
    padding: 6px 14px 4px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.dock-panel-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 10px;
}


/* ═══════════════════════════════════════════════════════════════════════════════
   IMMERSIVE WORKSPACE — Zone de travail centrale
   ═══════════════════════════════════════════════════════════════════════════════ */
#immersive-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    position: relative;
}


/* ─── Nav Bar (type navigateur) ──────────────────────────────────────────── */
#page-nav-bar {
    height: var(--navbar-h);
    flex-shrink: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    z-index: 10;
}

.nav-bar-inner {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0 8px;
    gap: 8px;
    min-width: 0;
}

.nav-bar-left {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.nav-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}

.nav-btn:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.nav-bar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 0;
    flex-shrink: 1;
    overflow: hidden;
}

.nav-breadcrumb-sphere {
    color: var(--text-muted);
    font-size: 11px;
}

.nav-breadcrumb-sep {
    color: var(--text-muted);
    font-size: 10px;
}

.nav-breadcrumb-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.nav-breadcrumb-text {
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Page Tabs (in nav bar) ──────────────────────────────────────────────── */
.nav-bar-tabs {
    display: flex;
    gap: 2px;
    margin-left: 16px;
    flex-shrink: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.nav-bar-tabs::-webkit-scrollbar {
    height: 0;
}

.nav-page-tab {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--t-fast), color var(--t-fast);
}

.nav-page-tab:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.nav-page-tab.active {
    background: var(--surface-active);
    color: var(--text-primary);
    font-weight: 500;
}

.nav-tab-icon {
    font-size: 12px;
}

.nav-bar-right {
    margin-left: auto;
    flex-shrink: 0;
}


/* ─── Page Container ─────────────────────────────────────────────────────── */
#page-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* ─── Home View (6 Bureau Zones) ──────────────────────────────────────────── */
#home-view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ─── Pages ──────────────────────────────────────────────────────────────── */
.atom-page {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--desktop-bg);
    overflow: hidden;
    animation: pageFadeIn var(--page-transition);
}

@keyframes pageFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.page-content {
    flex: 1;
    overflow: auto;
    position: relative;
}

.page-statusbar {
    height: 22px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}


/* ═══════════════════════════════════════════════════════════════════════════════
   BOTTOM BAR (remplace le taskbar classique)
   ═══════════════════════════════════════════════════════════════════════════════ */
#immersive-taskbar {
    height: var(--bottombar-h);
    display: flex;
    align-items: center;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 400;
    position: relative;
}

/* ─── Exec Tabs (gauche) ──────────────────────────────────────────────────── */
.taskbar-exec-tabs {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 8px;
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
}

.taskbar-exec-tabs::-webkit-scrollbar {
    height: 0;
}

/* ─── Minimap Globe (centre) ──────────────────────────────────────────────── */
.taskbar-minimap {
    width: var(--minimap-size);
    height: var(--minimap-size);
    flex-shrink: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #1a2440, #0a0a0f);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 0 12px;
    margin-top: -20px;  /* Overflow above the bar */
    cursor: pointer;
    transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
    z-index: 401;
}

.taskbar-minimap:hover {
    transform: scale(1.08);
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(0, 71, 171, 0.3);
}

.taskbar-minimap .minimap-icon {
    font-size: 24px;
    line-height: 1;
}
.taskbar-minimap .minimap-globe-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
}

/* Minimap quick links (orbit) */
.minimap-actions {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    z-index: 500;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.taskbar-minimap:hover .minimap-actions,
.minimap-actions.pinned {
    display: flex;
    animation: minimapPopup 0.2s ease;
}

@keyframes minimapPopup {
    from { opacity: 0; transform: translateX(-50%) translateY(4px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.minimap-action-row {
    display: flex;
    gap: 4px;
}

.minimap-action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}

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

.minimap-location {
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Comm Tabs (droite) ──────────────────────────────────────────────────── */
.taskbar-comm-tabs {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 8px;
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
    justify-content: flex-end;
}

.taskbar-comm-tabs::-webkit-scrollbar {
    height: 0;
}

/* ─── Bottom Bar Tabs (shared style) ──────────────────────────────────────── */
.bottombar-tab {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
    max-width: 160px;
    transition: background var(--t-fast), color var(--t-fast);
    position: relative;
}

.bottombar-tab:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.bottombar-tab.active {
    background: var(--surface-active);
    color: var(--text-primary);
}

/* Active indicator line */
.bottombar-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 8px;
    right: 8px;
    height: 2px;
    border-radius: 1px;
    background: var(--accent);
}

.bottombar-tab-icon {
    font-size: 13px;
    flex-shrink: 0;
}

.bottombar-tab-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bottombar-tab-close {
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity var(--t-fast), color var(--t-fast);
    padding: 0 2px;
    cursor: pointer;
    flex-shrink: 0;
}

.bottombar-tab:hover .bottombar-tab-close {
    opacity: 1;
}

.bottombar-tab-close:hover {
    color: #f44;
}


/* ═══════════════════════════════════════════════════════════════════════════════
   CONTEXT MENUS (Bottom Bar)
   ═══════════════════════════════════════════════════════════════════════════════ */
.context-menu {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    z-index: 500;
    min-width: 160px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.context-menu-item {
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: background var(--t-fast), color var(--t-fast);
}

.context-menu-item:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}


/* ═══════════════════════════════════════════════════════════════════════════════
   WORKSPACE LAYOUT ADJUSTMENTS (when docks expand)
   ═══════════════════════════════════════════════════════════════════════════════ */

/* When left dock is expanded, workspace adjusts */
#desktop-main.dock-left-expanded #immersive-workspace {
    /* Workspace naturally shrinks as dock expands due to flexbox */
}

/* When right dock is expanded */
#desktop-main.dock-right-expanded #immersive-workspace {
    /* Same — flexbox handles it */
}


/* ═══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE / MOBILE ADJUSTMENTS
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    :root {
        --dock-icon-w: 44px;
        --dock-expanded-w: 240px;
        --bottombar-h: 44px;
        --minimap-size: 56px;
    }

    .dock-icon-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .bottombar-tab {
        padding: 3px 8px;
        font-size: 10px;
        max-width: 120px;
    }

    .bottombar-tab-title {
        display: none;
    }

    .taskbar-minimap {
        margin-top: -14px;
    }
}

@media (max-width: 480px) {
    #dock-left,
    #dock-right {
        width: 0;
        border: none;
    }

    #dock-left.expanded,
    #dock-right.expanded {
        position: absolute;
        top: 0;
        bottom: 0;
        width: 80vw;
        z-index: 500;
        box-shadow: 0 0 40px rgba(0,0,0,0.6);
    }

    #dock-left.expanded { left: 0; }
    #dock-right.expanded { right: 0; }
}
