/* Mode Bar - Shared Navigation Styles */

/* Combined bar for Dossier pages - Terminal row + Dossier row */
.mode-bar-combined {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    z-index: 1001;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    /* Break out of body padding to fill full width */
    margin-left: -2rem;
    margin-right: -2rem;
    width: calc(100% + 4rem);
}

.mode-bar-combined .mode-bar-inner {
    display: flex;
    flex-direction: column;
}

/* Terminal pages: same combined bar, but flip row order (dossier row first, system access second) */
.mode-bar-terminal-flip .mode-bar-terminal-row { order: 2; }
.mode-bar-terminal-flip .mode-bar-dossier-row { order: 1; }

.mode-bar-combined .mode-bar-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
}

/* Terminal row within combined bar */
.mode-bar-combined .mode-bar-terminal-row {
    background: linear-gradient(180deg, #0a0a12 0%, #000000 100%);
    border-bottom: 1px solid #0066aa;
}

.mode-bar-combined .mode-bar-terminal-row .mode-bar-row-inner {
    max-width: 1000px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0;
}

.mode-bar-combined .terminal-label {
    color: #0066aa;
    font-family: 'VT323', monospace;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
}

.mode-bar-combined .terminal-links {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.mode-bar-combined .terminal-links a {
    color: #00aaff;
    text-decoration: none;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
    font-family: 'Share Tech Mono', monospace;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.mode-bar-combined .terminal-links a:hover {
    border-color: #0066aa;
    background: rgba(0, 170, 255, 0.1);
}

/* When on terminal pages, use 1100px to match terminal content width */
.mode-bar-terminal-flip .mode-bar-terminal-row .mode-bar-row-inner {
    max-width: 1100px;
}

.mode-bar-terminal-flip .mode-bar-dossier-row .mode-bar-row-inner {
    max-width: 1100px;
}

/* Dossier row within combined bar */
.mode-bar-combined .mode-bar-dossier-row {
    background: linear-gradient(180deg, #d4c896 0%, #c4b886 100%);
    border-bottom: 2px solid #b8a878;
    padding-top: 0.75rem;
    padding-bottom: 0;
}

.mode-bar-combined .mode-bar-dossier-row .mode-bar-row-inner {
    max-width: 1000px;
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    padding: 0;
}

.mode-bar-combined .dossier-label {
    color: #4a4035;
    font-family: 'Special Elite', cursive;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    align-self: flex-end;
    padding-bottom: 0.35rem;
}

.mode-bar-combined .dossier-links {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.mode-bar-combined .dossier-links a {
    color: #2a2418;
    text-decoration: none;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
    font-family: 'Special Elite', cursive;
    background: #e8dfc8;
    border: 1px solid #b8a878;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.mode-bar-combined .dossier-links a:hover {
    background: rgba(196, 169, 70, 0.4);
}

/* Dossier-style bar (appears on Terminal pages) */
.mode-bar-dossier {
    background: linear-gradient(180deg, #d4c896 0%, #c4b886 100%);
    border-bottom: 2px solid #b8a878;
    padding: 0.6rem 1rem;
    font-family: 'Courier Prime', 'Courier New', monospace;
    position: relative;
    z-index: 1001;
}

.mode-bar-dossier .mode-bar-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.mode-bar-dossier .mode-bar-label {
    color: #4a4035;
    font-family: 'Special Elite', cursive;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.mode-bar-dossier .mode-bar-links {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.mode-bar-dossier .mode-bar-links a {
    color: #2a2418;
    text-decoration: none;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
    font-family: 'Special Elite', cursive;
    background: #e8dfc8;
    border: 1px solid #b8a878;
    border-radius: 6px 6px 0 0;
    transition: all 0.2s;
}

.mode-bar-dossier .mode-bar-links a:hover {
    background: rgba(196, 169, 70, 0.4);
}

.mode-bar-dossier .mode-bar-links a.active {
    background: rgba(196, 169, 70, 0.5);
    border-color: #8b7355;
}

/* Terminal page in-content nav */
.term-nav {
    display: none;
}

.term-nav .nav-row {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.term-nav .nav-row a {
    font-family: 'VT323', monospace;
    font-size: 1.1rem;
    color: #0066aa;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.term-nav .nav-row a:hover {
    color: #00aaff;
    border-color: #0066aa;
}

.term-nav .nav-row a.active {
    color: #000;
    background: #00aaff;
    border-color: #00aaff;
}

/* Hide doc-nav on dossier pages (nav is in top bar now) */
.doc-nav {
    display: none;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .mode-bar-combined .mode-bar-row,
    .mode-bar-dossier {
        padding: 0.4rem 0.5rem;
    }
    
    .mode-bar-label,
    .terminal-label,
    .dossier-label {
        display: none;
    }
    
    .mode-bar-links a,
    .terminal-links a,
    .dossier-links a {
        padding: 0.25rem 0.4rem !important;
        font-size: 0.75rem !important;
    }
    
    .mode-bar-combined {
        margin-left: -1rem;
        margin-right: -1rem;
        width: calc(100% + 2rem);
    }
}

@media (max-width: 500px) {
    .mode-bar-combined {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        width: calc(100% + 1rem);
    }
    
    .mode-bar-links a,
    .terminal-links a,
    .dossier-links a {
        padding: 0.2rem 0.35rem !important;
        font-size: 0.65rem !important;
    }
    
    .mode-bar-combined .mode-bar-row-inner {
        gap: 0.5rem;
    }
    
    .mode-bar-combined .terminal-links,
    .mode-bar-combined .dossier-links {
        gap: 0.15rem;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SEARCH COMPONENT STYLES
   Terminal-style search that fits the A-SYNC aesthetic
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Text Fragment highlight (when scrolling to search match) */
::target-text {
    background: rgba(0, 255, 255, 0.3) !important;
    color: inherit !important;
}

/* Fallback for browsers using different pseudo-element */
::-moz-selection {
    background: rgba(0, 255, 255, 0.3);
}

.search-container {
    position: relative;
    margin-left: auto;
    flex-shrink: 0;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(0, 40, 70, 0.5);
    border: 1px solid #0077aa;
    border-radius: 3px;
    padding: 0.25rem 0.5rem;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.search-container.focused .search-input-wrapper {
    border-color: #00aadd;
    background: rgba(0, 50, 90, 0.7);
    box-shadow: 0 0 12px rgba(0, 170, 255, 0.3), inset 0 0 20px rgba(0, 100, 150, 0.2);
}

.search-icon {
    color: #00aacc;
    font-size: 0.9rem;
    opacity: 0.9;
}

.search-container.focused .search-icon {
    color: #00ccff;
    opacity: 1;
}

.search-input {
    background: transparent;
    border: none;
    outline: none;
    color: #00aaff;
    font-family: 'VT323', monospace;
    font-size: 0.95rem;
    width: 140px;
    letter-spacing: 0.05em;
}

.search-input::placeholder {
    color: #0088aa;
    opacity: 1;
}

.search-container.focused .search-input {
    width: 200px;
}

.search-shortcut {
    font-family: 'VT323', monospace;
    font-size: 0.75rem;
    color: #0099bb;
    background: rgba(0, 100, 140, 0.3);
    padding: 0.1rem 0.35rem;
    border-radius: 2px;
    border: 1px solid #0077aa;
}

.search-container.focused .search-shortcut {
    color: #00bbdd;
    border-color: #0099cc;
}

/* Search Results Dropdown */
.search-results {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 380px;
    max-height: 450px;
    overflow-y: auto;
    background: linear-gradient(180deg, #050510 0%, #000008 100%);
    border: 1px solid #0066aa;
    border-radius: 4px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(0, 100, 170, 0.15),
        inset 0 1px 0 rgba(0, 170, 255, 0.1);
    z-index: 2000;
    display: none;
}

.search-results.visible {
    display: block;
    animation: searchDropdown 0.15s ease-out;
}

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

/* Scrollbar styling for results */
.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: #000;
}

.search-results::-webkit-scrollbar-thumb {
    background: #003366;
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: #0066aa;
}

/* Individual result item */
.search-result {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    border-bottom: 1px solid #001a33;
    transition: background 0.15s ease;
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover,
.search-result.selected {
    background: rgba(0, 100, 170, 0.15);
}

.search-result.selected {
    border-left: 2px solid #00aaff;
    padding-left: calc(1rem - 2px);
}

.result-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.result-badge {
    font-family: 'VT323', monospace;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 2px;
    letter-spacing: 0.08em;
    flex-shrink: 0;
}

.result-badge-terminal {
    background: rgba(0, 170, 255, 0.2);
    color: #00aaff;
    border: 1px solid #0066aa;
}

.result-badge-dossier {
    background: rgba(196, 169, 70, 0.2);
    color: #c4a946;
    border: 1px solid #8b7355;
}

.result-badge-level {
    background: rgba(0, 204, 102, 0.15);
    color: #00cc66;
    border: 1px solid #006633;
}

.result-badge-event {
    background: rgba(204, 51, 51, 0.15);
    color: #cc5555;
    border: 1px solid #662222;
}

.result-title {
    font-family: 'VT323', monospace;
    font-size: 1rem;
    color: #00ccff;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-excerpt {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8rem;
    color: #006699;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Highlight matches */
.search-result mark {
    background: rgba(0, 170, 255, 0.3);
    color: #00ffff;
    padding: 0 0.1rem;
    border-radius: 1px;
}

/* No results state */
.search-no-results {
    padding: 2rem 1rem;
    text-align: center;
    color: #004466;
    font-family: 'VT323', monospace;
    font-size: 1rem;
}

.no-results-icon {
    display: block;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* Error state */
.search-error {
    padding: 1rem;
    color: #cc3333;
    font-family: 'VT323', monospace;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SEARCH MOBILE ADJUSTMENTS
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
    .search-input {
        width: 100px;
    }
    
    .search-container.focused .search-input {
        width: 160px;
    }
    
    .search-results {
        width: 320px;
    }
}

@media (max-width: 768px) {
    .search-container {
        position: static;
    }
    
    .search-input {
        width: 80px;
        font-size: 0.85rem;
    }
    
    .search-container.focused .search-input {
        width: 120px;
    }
    
    .search-input-wrapper {
        padding: 0.2rem 0.4rem;
    }
    
    .search-shortcut {
        display: none;
    }
    
    .search-results {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 60vh;
        border-radius: 12px 12px 0 0;
        border-bottom: none;
    }
    
    .search-result {
        padding: 1rem;
    }
}

@media (max-width: 500px) {
    .search-input::placeholder {
        content: 'Search...';
    }
    
    .search-input {
        width: 60px;
    }
    
    .search-container.focused .search-input {
        width: 100px;
    }
    
    .search-icon {
        font-size: 0.8rem;
    }
}
