/* ===========================================================
   PORTAIL DOCUMENTAIRE INSTITUTIONNEL
   Design System — Prestige × Praticité
   =========================================================== */

/* ---- RESET ---- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ---- TOKENS ---- */
:root {
    /* Palette institutionnelle marocaine */
    --blue: #0B3D91;
    --blue-dark: #062A64;
    --blue-light: #1A56B8;
    --blue-wash: rgba(11, 61, 145, .06);
    --gold: #C8902E;
    --gold-light: #E5A93D;
    --gold-wash: rgba(200, 144, 46, .08);
    --bordeaux: #7A1B3E;
    --bordeaux-wash: rgba(122, 27, 62, .07);
    --green: #10B981;
    --green-wash: rgba(16, 185, 129, .07);

    --surface: #FFFFFF;
    --surface-alt: #F5F7FA;
    --surface-hov: #EDF0F7;
    --text: #1A1F36;
    --text-2: #4A5568;
    --text-3: #8492A6;
    --border: #E2E8F0;
    --border-lt: #EDF2F7;

    --shadow-xs: 0 1px 2px rgba(11, 61, 145, .04);
    --shadow-sm: 0 1px 4px rgba(11, 61, 145, .06);
    --shadow-md: 0 4px 16px rgba(11, 61, 145, .07);
    --shadow-lg: 0 12px 40px rgba(11, 61, 145, .10);
    --shadow-xl: 0 20px 60px rgba(11, 61, 145, .14);

    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 16px;
    --r-xl: 24px;
    --ease: .25s cubic-bezier(.4, 0, .2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-ar: 'Noto Kufi Arabic', var(--font);
    --max-w: 1320px;
    --nav-h: 68px;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    background: var(--surface-alt);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 2rem;
}

.hidden {
    display: none !important;
}

img {
    max-width: 100%;
    display: block;
}

button {
    font-family: var(--font);
    cursor: pointer;
}

/* ---- ANIMATIONS ---- */
.fade-in {
    animation: fadeUp .55s var(--ease) both;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(18px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

@keyframes pulseDot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1)
    }

    50% {
        opacity: .45;
        transform: scale(.75)
    }
}

@keyframes shimmer {
    to {
        background-position: 200% center
    }
}

/* ===========================================================
   NAVBAR
   =========================================================== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 900;
    height: var(--nav-h);
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid var(--border-lt);
    transition: box-shadow var(--ease);
}

.navbar.scrolled {
    box-shadow: var(--shadow-md);
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--nav-h);
}
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    cursor: pointer;
}

.logo-emblem {
    width: 40px;
    height: 40px;
    border-radius: var(--r-sm);
    background: linear-gradient(135deg, var(--blue), var(--blue-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 2px 8px rgba(11, 61, 145, .22);
}

.logo-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.logo-info {
    display: flex;
    flex-direction: column;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-main {
    font-weight: 800;
    font-size: 1.35rem;
    color: var(--blue-dark);
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

.logo-org {
    font-size: .68rem;
    font-weight: 500;
    color: var(--text-3);
    letter-spacing: .03em;
    text-transform: uppercase;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-btn {
    padding: 7px 16px;
    border: none;
    border-radius: var(--r-sm);
    font-size: .8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--ease);
}

.nav-btn-ghost {
    background: transparent;
    color: var(--text-2);
}

.nav-btn-ghost:hover {
    background: var(--surface-hov);
    color: var(--blue);
}

.lang-toggle {
    padding: 6px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-2);
    transition: var(--ease);
}

.lang-toggle:hover {
    border-color: var(--blue-light);
    color: var(--blue);
}

/* ===========================================================
   HERO
   =========================================================== */
.hero {
    position: relative;
    padding: 120px 0 72px;
    background: linear-gradient(168deg, var(--blue-dark) 0%, var(--blue) 55%, var(--blue-light) 100%);
    overflow: visible !important; /* Force visibility for autocomplete */
}

.hero-zellige {
    position: absolute;
    inset: 0;
    opacity: .035;
    overflow: hidden;  /* overflow ici à la place du parent */
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 58px, rgba(255, 255, 255, .12) 58px, rgba(255, 255, 255, .12) 60px),
        repeating-linear-gradient(90deg, transparent, transparent 58px, rgba(255, 255, 255, .12) 58px, rgba(255, 255, 255, .12) 60px),
        repeating-linear-gradient(45deg, transparent, transparent 82px, rgba(255, 255, 255, .06) 82px, rgba(255, 255, 255, .06) 83px),
        repeating-linear-gradient(-45deg, transparent, transparent 82px, rgba(255, 255, 255, .06) 82px, rgba(255, 255, 255, .06) 83px);
    pointer-events: none;
}

.hero-gradient {
    position: absolute;
    inset: 0;
    overflow: hidden;  /* overflow ici à la place du parent */
    background:
        radial-gradient(ellipse 70% 55% at 15% 85%, rgba(200, 144, 46, .1) 0%, transparent 70%),
        radial-gradient(ellipse 50% 40% at 85% 15%, rgba(255, 255, 255, .06) 0%, transparent 60%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 100;
    text-align: center;
    max-width: 760px;
    margin: 0 auto;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 18px;
    margin-bottom: 26px;
    background: rgba(255, 255, 255, .09);
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: 100px;
    color: rgba(255, 255, 255, .8);
    font-size: .76rem;
    font-weight: 500;
    letter-spacing: .03em;
    backdrop-filter: blur(8px);
}

.hero-badge-dot {
    width: 6px;
    height: 6px;
    background: var(--gold-light);
    border-radius: 50%;
    animation: pulseDot 2s ease-in-out infinite;
}

.hero-title {
    font-size: clamp(1.9rem, 4vw, 2.85rem);
    font-weight: 800;
    color: #fff;
    line-height: 1.15;
    margin-bottom: 16px;
    letter-spacing: -.02em;
}

.hero-subtitle {
    font-size: clamp(.9rem, 1.4vw, 1.1rem);
    color: rgba(255, 255, 255, .65);
    line-height: 1.7;
    margin-bottom: 40px;
    max-width: 580px;
    margin-left: auto;
    margin-right: auto;
}

/* ===========================================================
   OMNIBOX / SEARCH
   =========================================================== */
.search-container {
    position: relative;
    max-width: 660px;
    margin: 0 auto;
    z-index: 50;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, .97);
    border-radius: 14px;
    padding: 6px 6px 6px 20px;
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255, 255, 255, .15);
    transition: var(--ease);
}

.search-bar:focus-within {
    box-shadow: var(--shadow-xl), 0 0 0 3px rgba(200, 144, 46, .35);
    transform: translateY(-1px);
}

.search-icon {
    display: flex;
    align-items: center;
    color: var(--text-3);
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font);
    font-size: .93rem;
    color: var(--text);
    padding: 13px 6px;
}

.search-bar input::placeholder {
    color: var(--text-3);
}

.btn-clear {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--r-sm);
    background: var(--surface-hov);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    transition: var(--ease);
}

.btn-clear:hover {
    background: #fee2e2;
    color: #dc2626;
}

.search-submit {
    padding: 11px 26px;
    border: none;
    border-radius: 10px;
    background: var(--blue);
    color: #fff;
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
    transition: var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.search-submit:hover {
    background: var(--blue-light);
}

.search-submit-icon {
    display: none;
}

/* Autocomplete */
.autocomplete-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: var(--r-md);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border: 1px solid var(--border-lt);
    max-height: 480px;
    overflow-y: auto;
    z-index: 2000; /* Extremely high to overtop stats-bar */
}

.ac-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 18px;
    cursor: pointer;
    transition: background var(--ease);
    border-bottom: 1px solid var(--border-lt);
}

.ac-item:last-child {
    border-bottom: none;
}

.ac-item:hover,
.ac-item.active {
    background: var(--blue-wash);
}

.ac-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.ac-icon.guide {
    background: var(--blue-wash);
}

.ac-icon.kit {
    background: var(--gold-wash);
}

.ac-icon.form {
    background: var(--green-wash);
}

.ac-icon.proc {
    background: var(--bordeaux-wash);
}

.ac-body {
    flex: 1;
    min-width: 0;
}

.ac-title {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
}

.ac-excerpt {
    font-size: .78rem;
    color: var(--text-2);
    line-height: 1.55;
    margin-top: 2px;
}

.ac-excerpt mark,
.ac-title mark {
    background: rgba(200, 144, 46, .2);
    color: var(--text);
    padding: 0 2px;
    border-radius: 2px;
    font-weight: inherit;
}

.ac-type {
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-3);
    margin-top: 3px;
}

/* Shortcuts */
.search-shortcuts {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 22px;
    flex-wrap: wrap;
}

.shortcut-chip {
    padding: 6px 16px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 100px;
    background: rgba(255, 255, 255, .1);
    color: rgba(255, 255, 255, .72);
    font-size: .78rem;
    font-weight: 500;
    transition: var(--ease);
    backdrop-filter: blur(8px);
}

.shortcut-chip:hover {
    background: rgba(255, 255, 255, .18);
    color: #fff;
}

/* ===========================================================
   STATS BAR
   =========================================================== */
.stats-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border-lt);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* Back to 4 columns */
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 22px 24px;
    border-right: 1px solid var(--border-lt);
    transition: background var(--ease);
}

.stat-item:last-child {
    border-right: none;
}

.stat-item:hover {
    background: var(--surface-alt);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.si-blue {
    background: var(--blue-wash);
    color: var(--blue);
}

.si-gold {
    background: var(--gold-wash);
    color: var(--gold);
}

.si-green {
    background: var(--green-wash);
    color: var(--green);
}

.si-bordeaux {
    background: var(--bordeaux-wash);
    color: var(--bordeaux);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -.02em;
}

/* Quick Nav Section (Home) */
.quick-nav-section {
    padding: 30px 0;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-lt);
}

.quick-nav-card {
    background: #fff;
    border: 1px solid var(--blue-light);
    border-left: 5px solid var(--blue);
    border-radius: var(--r-md);
    padding: 24px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    box-shadow: 0 10px 30px rgba(11, 61, 145, 0.08);
}

.qn-head {
    display: flex;
    align-items: center;
    gap: 20px;
}

.qn-ico {
    font-size: 2.2rem;
    background: var(--blue-wash);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.qn-info {
    display: flex;
    flex-direction: column;
}

.qn-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--blue);
    letter-spacing: 0.1em;
    margin-bottom: 4px;
}

.qn-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.quick-jump-select {
    flex: 1;
    max-width: 450px;
    border: 2px solid var(--border-lt);
    background: #fff;
    padding: 12px 18px;
    border-radius: var(--r-sm);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.quick-jump-select:hover {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px var(--blue-wash);
}

.stat-label {
    font-size: .75rem;
    color: var(--text-3);
    font-weight: 500;
    margin-top: 1px;
}

/* ===========================================================
   HOME — COMPACT THUMBNAIL GRID
   =========================================================== */
.home-main {
    padding: 40px 0 64px;
}

.card-section {
    margin-bottom: 44px;
}

.card-section:last-child {
    margin-bottom: 0;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-lt);
}

.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-blue     { background: var(--blue); }
.dot-gold     { background: var(--gold); }
.dot-green    { background: var(--green); }
.dot-bordeaux { background: var(--bordeaux); }

.section-count {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-3);
    background: var(--surface-hov);
    padding: 3px 10px;
    border-radius: 100px;
}

.section-more {
    border: none;
    background: none;
    font-size: .82rem;
    font-weight: 600;
    color: var(--blue);
    transition: var(--ease);
    padding: 4px 12px;
    border-radius: var(--r-sm);
}

.section-more:hover {
    background: var(--blue-wash);
    color: var(--blue-dark);
}

/* Thumbnail grid — 6 columns */
.cards-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

/* Single compact thumbnail */
.doc-thumb {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border-lt);
    border-radius: var(--r-md);
    padding: 14px 12px 12px;
    cursor: pointer;
    overflow: visible;           /* tooltip must overflow */
    transition: box-shadow var(--ease), border-color var(--ease), transform var(--ease);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 90px;
}

.doc-thumb::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--r-md) var(--r-md) 0 0;
    opacity: 0;
    transition: opacity var(--ease);
}

.doc-thumb[data-type="guide"]::before   { background: var(--blue); }
.doc-thumb[data-type="kit"]::before     { background: var(--gold); }
.doc-thumb[data-type="document"]::before{ background: var(--green); }

.doc-thumb:hover {
    border-color: rgba(11, 61, 145, .18);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    z-index: 10;
}

.doc-thumb:hover::before { opacity: 1; }

.thumb-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.thumb-ico {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .88rem;
    flex-shrink: 0;
}
.thumb-ico.guide    { background: var(--blue-wash); }
.thumb-ico.kit      { background: var(--gold-wash); }
.thumb-ico.form     { background: var(--green-wash); }
.thumb-ico.proc     { background: var(--bordeaux-wash); }

.thumb-badge {
    font-size: .58rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 100px;
    line-height: 1.6;
}
.badge-guide { background: var(--blue-wash);     color: var(--blue); }
.badge-kit   { background: var(--gold-wash);     color: var(--gold); }
.badge-form  { background: var(--green-wash);    color: var(--green); }
.badge-proc  { background: var(--bordeaux-wash); color: var(--bordeaux); }

.thumb-title {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.doc-thumb:hover .thumb-title {
    color: var(--blue);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ── Hover Tooltip ── */
.thumb-tooltip {
    display: none;
    position: absolute;
    left: 50%;
    top: calc(100% + 10px);
    transform: translateX(-50%);
    width: 260px;
    background: #fff;
    border: 1px solid var(--border-lt);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xl);
    padding: 16px;
    z-index: 200;
    pointer-events: none;
    animation: fadeUp .18s var(--ease) both;
}

/* prevent tooltip from being cut off at edges */
.cards-row .doc-thumb:nth-child(6n+5) .thumb-tooltip,
.cards-row .doc-thumb:nth-child(6n) .thumb-tooltip {
    left: auto;
    right: 0;
    transform: none;
}

.doc-thumb:hover .thumb-tooltip {
    display: block;
    pointer-events: auto;
}

.tt-title {
    font-size: .88rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1.35;
}

.tt-desc {
    font-size: .77rem;
    color: var(--text-2);
    line-height: 1.6;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tt-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .68rem;
    color: var(--text-3);
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-lt);
}

.tt-cat {
    background: var(--surface-hov);
    padding: 2px 8px;
    border-radius: 100px;
    font-weight: 500;
}

.tt-btn {
    width: 100%;
    padding: 8px 0;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: var(--r-sm);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--ease);
}

.tt-btn:hover { background: var(--blue-light); }

/* ===========================================================
   WORKSPACE — Windowed Mode (allows footer below)
   =========================================================== */

.workspace {
    position: relative;
    display: flex; /* Switched to flex for more robust sidebar collapse */
    align-items: stretch;
    margin-top: var(--nav-h);
    background: var(--surface-alt);
    height: calc(100vh - var(--nav-h));
    min-height: 500px;
    border-bottom: 1px solid var(--border-lt);
    z-index: 10;
    overflow: hidden;
}

.workspace.ws-collapsed .ws-sidebar {
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    opacity: 0 !important;
    pointer-events: none;
    border: none !important;
}

.ws-sidebar {
    background: #fff;
    border-right: 1px solid var(--border-lt);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 370px;
    height: 100%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.ws-viewer {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    height: 100%;
}

/* persistent search badge in workspace */
.ws-search-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--blue-wash), #eef2ff);
    color: var(--blue-dark);
    font-size: .78rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 8px;
    margin: 12px 0 4px;
    border: 1px solid rgba(11, 61, 145, .1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}
.ws-search-badge mark {
    background: var(--gold-wash);
    color: var(--gold-dark);
    padding: 0 5px;
    border-radius: 3px;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1);
}
.ws-search-badge button {
    background: none;
    border: none;
    color: var(--blue);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    margin-left: 4px;
}
.ws-search-badge button:hover {
    color: var(--bordeaux);
}

/* Sidebar */
.ws-sidebar {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border-lt);
    overflow: hidden;
    height: 100%;          /* ← fill grid cell */
    min-height: 0;         /* ← allow flex shrinking */
}

.ws-sidebar-head {
    padding: 24px 20px 18px;
    background: linear-gradient(to bottom, #f0f7ff, #fff); /* More prominent blue-wash at top */
    border-bottom: 2px solid var(--blue-light);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.ws-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border-lt);
    background: #fff;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 16px;
    padding: 6px 14px;
    border-radius: 100px;
    width: fit-content;
    transition: all var(--ease);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.ws-back svg {
    color: var(--blue);
}

.ws-back:hover {
    background: var(--surface-alt);
    border-color: var(--blue-light);
    color: var(--blue);
    transform: translateX(-2px);
}

.ws-theme {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 4px;
    letter-spacing: -.01em;
}

.ws-filter-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface-alt);
    transition: var(--ease);
}

.ws-filter-box:focus-within {
    border-color: var(--blue-light);
    background: #fff;
    box-shadow: 0 0 0 3px var(--blue-wash);
}

.ws-filter-icon {
    color: var(--text-3);
    flex-shrink: 0;
}

.ws-viewer-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #525659;
    cursor: pointer; /* "Main doigt" for the whole area */
}

.ws-filter-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 9px 0;
    font-family: var(--font);
    font-size: .83rem;
    color: var(--text);
}

.ws-count {
    display: block;
    margin-top: 10px;
    font-size: .75rem;
    color: var(--text-3);
    font-weight: 500;
}

.ws-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.ws-list::-webkit-scrollbar {
    width: 4px;
}

.ws-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.ws-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    cursor: pointer !important; /* "Main doigt" for all items */
    transition: var(--ease);
    margin-bottom: 2px;
    border: 1.5px solid transparent;
}

.ws-item:hover {
    background: var(--surface-alt);
}

.ws-item.selected {
    background: var(--blue-wash);
    border-color: rgba(11, 61, 145, .15);
}

.ws-item-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}

.ws-item-body {
    flex: 1;
    min-width: 0;
}

.ws-item-title {
    font-size: .84rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
}

.ws-item-title mark {
    background: rgba(200, 144, 46, .22);
    color: var(--text);
    padding: 0 2px;
    border-radius: 2px;
}

.ws-item-excerpt {
    font-size: .76rem;
    color: var(--text-2);
    line-height: 1.5;
    margin-top: 3px;
}

.ws-item-excerpt mark {
    background: rgba(200, 144, 46, .22);
    color: var(--text);
    padding: 0 2px;
    border-radius: 2px;
}

.ws-item-type {
    font-size: .63rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-3);
    margin-top: 4px;
}

/* Viewer */
.ws-viewer {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    height: 100%;          /* ← fill grid cell */
    min-height: 0;         /* ← allow flex shrinking */
}

.ws-viewer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 22px;
    background: rgba(248, 250, 252, 0.85); /* Semi-transparent for floating feel */
    backdrop-filter: blur(12px); /* Glassmorphism */
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 12px;
    min-height: 60px;
    z-index: 100; /* Ensure it stays above floating navs */
    position: sticky;
    top: 0;
}

.ws-viewer-info {
    flex: 1;
    min-width: 0;
}

.ws-viewer-title {
    font-size: .98rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ws-viewer-relation {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.relation-lbl {
    font-size: .72rem;
    color: var(--text-3);
}

.relation-a {
    font-size: .75rem;
    font-weight: 600;
    color: var(--blue);
    text-decoration: none;
}

.relation-a:hover {
    color: var(--gold);
}

.ws-viewer-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.ws-ctrl {
    width: 34px;
    height: 34px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--ease);
    cursor: pointer; /* Universal Hand Cursor */
}

.ws-ctrl:hover:not(:disabled) {
    background: var(--surface-alt);
    border-color: var(--blue-light);
    color: var(--blue);
}

.ws-ctrl:disabled {
    opacity: .3;
    cursor: not-allowed;
}

.ws-ctrl-danger:hover:not(:disabled) {
    background: #fef2f2 !important;
    border-color: #fca5a5 !important;
    color: #dc2626 !important;
}

.ws-ctrl-sep {
    width: 1px;
    height: 20px;
    background: var(--border-lt);
    margin: 0 4px;
}

.ws-counter {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-3);
    min-width: 36px;
    text-align: center;
}

.ws-viewer-body {
    flex: 1 1 0;           /* flex-grow:1, flex-shrink:1, flex-basis:0 — fills remaining height */
    position: relative;
    overflow: hidden;
    min-height: 0;         /* ← critical: allows flex children to shrink below content size */
}

.ws-viewer-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    cursor: pointer; /* Ensure pointer persists through iframe if possible */
}

.ws-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
    cursor: grab;
}

.ws-iframe:active {
    cursor: grabbing;
}

/* ===========================================================
   MOBILE OPTIMIZATION
   =========================================================== */
@media (max-width: 900px) {
    .workspace {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
    }

    .ws-sidebar {
        display: none !important; /* Force hide on mobile in workspace */
    }

    .workspace.ws-mobile-show-sidebar .ws-sidebar {
        display: flex;
        position: fixed;
        top: var(--nav-h);
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1001;
        background: #fff;
    }

    .ws-viewer-head {
        padding: 12px 16px;
        background: var(--surface-alt);
    }

    .ws-viewer-title h2 {
        font-size: 1rem;
    }

    .ws-nav-float {
        width: 56px;
        height: 56px;
        right: 20px;
    }

    .ws-float-down { bottom: 30px; }
    .ws-float-up { bottom: 100px; }

    /* Smartphone PDF optimization - ensure flex fill */
    .ws-viewer {
        height: calc(100vh - 60px); /* Fill space below small header */
    }
    .ws-viewer-content {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
}

@media (max-width: 600px) {
    .hero-title { font-size: 2.2rem; }
    .stats-container { grid-template-columns: 1fr; }
    .cards-row { grid-template-columns: 1fr; }
    
    .logo-main { font-size: 1rem; }
    .logo-icon { font-size: 1.4rem; }
}
/* Floating Nav Arrows */
.ws-nav-float {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 64px; /* Wider for labels */
    height: 64px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid var(--blue-light);
    color: var(--blue);
    display: flex;
    flex-direction: column; /* Stack ico + lbl */
    align-items: center;
    justify-content: center;
    z-index: 999;
    cursor: pointer !important; /* Ensure main doigt */
    transition: all 0.3s var(--ease);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0.35;
}

.ws-nav-lbl {
    font-size: 0.58rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-top: 4px;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

.ws-viewer-body:hover .ws-nav-float:not(:disabled) {
    opacity: 0.98;
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 12px 30px rgba(0,0,0,0.2);
}

.ws-float-prev { left: 24px; }
.ws-float-next { right: 24px; }

.ws-nav-float:hover {
    background: var(--blue);
    color: #fff;
    box-shadow: 0 8px 24px rgba(11, 61, 145, 0.25);
    opacity: 1 !important;
}

.ws-nav-float:active {
    transform: translateY(-50%) scale(0.95);
}

.ws-nav-float:disabled {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Hide navigation if iframe is empty */
.ws-iframe.hidden ~ .ws-nav-float {
    display: none;
}

.ws-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-3);
    font-size: .88rem;
}

/* ===========================================================
   FOOTER
   =========================================================== */
.site-footer {
    background: var(--blue-dark);
    color: rgba(255, 255, 255, .55);
    padding: 36px 0;
}

.footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.footer-brand {
    font-size: .85rem;
    font-weight: 700;
    color: rgba(255, 255, 255, .8);
    letter-spacing: .04em;
}

.footer-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: rgba(255, 255, 255, .45);
    text-decoration: none;
    font-size: .78rem;
    font-weight: 500;
    transition: var(--ease);
}

.footer-links a:hover {
    color: #fff;
}

.footer-copy {
    font-size: .72rem;
    color: rgba(255, 255, 255, .3);
}

/* ===========================================================
   PARENT PDF TOOLBAR (Unified)
   =========================================================== */
.parent-pdf-toolbar {
    position: fixed;
    bottom: 24px;
    left: 370px; /* Aligned with sidebar width */
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(43, 46, 59, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: #fff;
    z-index: 2500;
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    width: fit-content;
    margin: 0 auto;
}

.workspace.ws-collapsed .parent-pdf-toolbar {
    left: 0;
}

@media(max-width:900px) {
    .parent-pdf-toolbar {
        left: 0 !important;
        right: 0 !important;
        bottom: 20px;
        padding: 6px 12px;
        gap: 6px;
        max-width: calc(100vw - 32px);
    }
    .parent-pdf-toolbar .btn-lbl {
        display: none !important;
    }
    .parent-pdf-toolbar button, 
    .parent-pdf-toolbar .btn-dl {
        padding: 8px 10px;
        font-size: 0.9rem;
    }
    .parent-pdf-toolbar .sep {
        display: none;
    }
    .parent-pdf-toolbar input {
        width: 38px;
        height: 28px;
    }
    .parent-pdf-toolbar span {
        font-size: 0.8rem;
    }
}

.parent-pdf-toolbar button {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--ease);
    display: flex;
    align-items: center;
    gap: 6px;
}

.parent-pdf-toolbar button:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
    transform: translateY(-1px);
}

.parent-pdf-toolbar input {
    width: 44px;
    height: 30px;
    background: #fff;
    border: none;
    text-align: center;
    border-radius: 4px;
    font-weight: 800;
    color: var(--text);
    font-size: 0.9rem;
}

.parent-pdf-toolbar span {
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0.8;
}

.parent-pdf-toolbar .sep {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.2);
    margin: 0 4px;
}

.parent-pdf-toolbar .btn-dl {
    background: var(--gold);
    color: #fff !important;
    font-weight: 700;
    border: none;
    text-decoration: none;
    padding: 7px 18px;
    border-radius: 50px;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--ease);
}

.parent-pdf-toolbar .btn-dl:hover {
    background: var(--gold-light);
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(200, 144, 46, 0.4);
}

/* ===========================================================
   RESPONSIVE
   =========================================================== */
@media(max-width:1100px) {
    .cards-row {
        grid-template-columns: repeat(3, 1fr);
    }

    .workspace {
        grid-template-columns: 320px 1fr;
    }
}

@media(max-width:900px) {
    .cards-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-item:nth-child(2) {
        border-right: none;
    }
}

@media(max-width:768px) {
    .container {
        padding: 0 1.2rem;
    }

    /* Fixed Quick Jump Responsive */
    .quick-nav-card {
        flex-direction: column;
        align-items: stretch;
        gap: 20px;
        padding: 20px;
        text-align: center;
    }
    .qn-head {
        flex-direction: column;
        gap: 12px;
    }
    .quick-jump-select {
        max-width: 100%;
        width: 100%;
    }

    .hero {
        padding: 130px 0 70px;
    }

    .search-bar {
        padding: 5px 5px 5px 12px;
        gap: 4px;
    }

    .search-submit {
        padding: 10px 14px;
    }

    .search-submit-text {
        display: none;
    }

    .search-submit-icon {
        display: block;
    }

    .cards-row {
        grid-template-columns: 1fr;
    }

    body.workspace-active {
        overflow: auto !important; /* Restore natural scroll */
        height: auto;
    }

    .workspace {
        display: block;
        position: relative;
        height: auto;
        min-height: 100vh;
        z-index: 100;
        background: #fff;
    }

    .ws-viewer {
        width: 100%;
        display: block;
        min-height: 100vh;
    }

    .ws-viewer iframe {
        width: 100%;
        height: auto; /* Allow expand on mobile */
        min-height: 600px;
        border: none;
    }


    /* Mobile Sidebar as Overlay */
    .ws-sidebar {
        position: fixed;
        left: 0;
        top: var(--nav-h);
        bottom: 0;
        width: 280px;
        z-index: 2000;
        transform: translateX(-100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex !important; /* Always visible to JS but off-screen */
        background: #fff;
        box-shadow: 10px 0 40px rgba(0,0,0,0.2);
        border-right: 1px solid var(--border);
    }

    /* Toggle Logic: Sidebar is OPEN by default in desktop, 
       but on mobile we use .ws-collapsed-active or similar? 
       Actually, standard is .ws-collapsed skips it. 
       Let's use a specific mobile class if needed, or stick to .ws-collapsed.
    */
    .workspace.ws-collapsed .ws-sidebar {
        transform: translateX(-100%);
    }
    .workspace:not(.ws-collapsed) .ws-sidebar {
        transform: translateX(0);
    }

    /* Adjust viewer title on mobile */
    .ws-viewer-title {
        font-size: 0.8rem !important;
        white-space: normal !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        line-clamp: 2;
        overflow: hidden;
        max-width: 140px;
        line-height: 1.2;
    }

    .ws-sidebar-head {
        display: flex;
        flex-direction: column;
        padding: 16px;
        position: relative;
    }

    .ws-sidebar-close {
        position: absolute;
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        border: none;
        background: var(--surface-alt);
        color: var(--text-2);
        font-size: 1.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 10;
        line-height: 1;
        transition: var(--ease);
    }

    .ws-sidebar-close:hover {
        background: #fee2e2;
        color: #ef4444;
    }

    .ws-viewer-head {
        position: relative;
        top: 0;
        flex-shrink: 0;
        z-index: 100;
        padding: 8px 12px;
        background: #fff;
        border-bottom: 1px solid var(--border);
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }

    .ws-viewer-controls {
        gap: 3px;
    }

    .ws-ctrl {
        width: 30px;
        height: 30px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .ws-ctrl svg {
        width: 16px;
        height: 16px;
    }

    .ws-counter {
        font-size: 0.7rem;
        min-width: 45px;
    }

    .nav-btn-ghost {
        display: none;
    }

    /* Floating Nav Mobile Position Fix */
    .ws-nav-float {
        width: 48px;
        height: 48px;
        right: 12px;
        opacity: 0.8;
    }
    .ws-nav-lbl {
        display: none; /* Hide labels on mobile to prevent overlap */
    }
    .ws-float-down { bottom: 20px; }
    .ws-float-up { bottom: 80px; }

    /* Universal Pointer for mobile touches */
    .ws-item {
        cursor: pointer;
        padding: 10px 14px;
    }
}

@media(max-width:480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-item {
        border-right: none !important;
        border-bottom: 1px solid var(--border-lt);
    }
}