/* ================================================================
# DACOG Search Engine – System Architecture
# Version: 3.5.0 (Reconciled & Mathematical)
# Description: Global Settings Framework (Zero-Overflow/Fluid)
# Supports: Chrome, Firefox, Safari, Edge, Opera, IE Legacy
================================================================ */

:root {
    /* --- DACOG Brand Identity --- */
    --dacog-primary: #0056b3; 
    --dacog-accent: #ffcc00;
    --dacog-success: #28a745;
    --dacog-danger: #dc3545;
    
    /* --- Mathematical Scaling (Mathematical Units) --- */
    --spacing-unit: 1rem;
    --border-radius-sm: 0.25rem;
    --border-radius-md: 0.5rem;
    --border-radius-lg: 1rem;
    --border-width: 0.0625rem; /* Precise 1px equivalent */
    
    /* --- Shadow Architecture --- */
    --shadow-sm: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
    --shadow-md: 0 0.5rem 1rem rgba(0,0,0,0.15);
    
    /* --- Default Light/Hero Theme --- */
    --bg-portal: #ffffff;
    --bg-base: #f8f9fa;
    --bg-nav: #f1f3f5;
    --text-main: #212529;
    --text-muted: #6c757d;
    --surface-card: #ffffff;
    --border-color: #dee2e6;
    --input-bg: #f8f9fa;
}

[data-theme="dark"] {
    /* --- Dark Theme Intelligence --- */
    --bg-portal: #121212;
    --bg-base: #1a1a1a;
    --bg-nav: #252525;
    --text-main: #e0e0e0;
    --text-muted: #a0a0a0;
    --surface-card: #1e1e1e;
    --border-color: #333333;
    --input-bg: #2d2d2d;
}

/* 1. Global Reset & Safety Gate */
html, body {
    max-width: 100vw;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background-color: var(--bg-portal);
    color: var(--text-main);
    font-size: 100%; /* Responsive Base */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    font-family: system-ui, -apple-system, sans-serif;
}

/* 2. Layout & Sidebar Intelligence */
.settings-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.dacog-settings-nav {
    display: flex;
    flex-direction: column;
}

.dacog-settings-nav .nav-link {
    color: var(--text-muted);
    border-radius: var(--border-radius-md);
    padding: 0.75rem 1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
}

.dacog-settings-nav .nav-link:hover {
    background-color: var(--bg-nav);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.dacog-settings-nav .nav-link.active {
    background-color: rgba(0, 86, 179, 0.1);
    color: var(--dacog-primary);
    font-weight: 600;
}

/* 3. Settings Card Architecture (Zero Overflow) */
.settings-card {
    background-color: var(--surface-card);
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.settings-card-header {
    background-color: var(--surface-card);
    border-bottom: var(--border-width) solid var(--border-color);
    padding: 1.5rem 1.5rem 1rem 1.5rem;
}

.dacog-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: var(--border-width) solid var(--border-color);
    transition: background-color 0.2s ease;
}

.dacog-setting-row:last-child {
    border-bottom: none;
}

.dacog-setting-row:hover {
    background-color: var(--bg-base);
}

/* 4. Interactive Elements */
.settings-avatar {
    width: 3.75rem;
    height: 3.75rem;
    border-radius: 50%;
    font-size: 1.75rem;
}

.context-menu {
    position: absolute;
    z-index: 1000;
    background: var(--surface-card);
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    min-width: 12rem;
    padding: 0.5rem 0;
}

.context-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.context-menu li {
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    color: var(--text-main);
    transition: background 0.2s ease;
}

.context-menu li:hover {
    background: var(--dacog-primary);
    color: #ffffff;
}

/* 5. Target Africa Optimization (480px Breakpoint) */
@media screen and (max-width: 30em) {
    .settings-header-block {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .dacog-settings-nav {
        flex-direction: row !important;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
        margin-bottom: 1rem;
        border-bottom: var(--border-width) solid var(--border-color);
    }

    .dacog-settings-nav .nav-link {
        display: inline-block;
        margin-right: 0.5rem;
        padding: 0.5rem 0.75rem;
    }

    .dacog-setting-row {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .context-menu {
        min-width: 85vw;
        left: 7.5vw !important;
    }
}

.context-menu li.text-primary {
    border-top: var(--border-width) solid var(--border-color);
    margin-top: 0.25rem;
    color: var(--dacog-primary);
    font-weight: 700;
}

/* Mobile Long-Press optimization for Africa (480px) */
@media screen and (max-width: 30rem) {
    .context-menu li.text-primary {
        padding: 1.25rem;
        background-color: rgba(0, 86, 179, 0.05);
    }
}

/* 6. Landscape Orientation Mobile Fix */
@media screen and (max-height: 30em) and (orientation: landscape) {
    .dacog-setting-row { padding: 0.75rem 1rem; }
    .settings-card-header { padding: 1rem; }
}

/* 7. Legacy Browser Compatibility (IE11/Safari Older) */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    .settings-wrapper { display: block; }
    .dacog-setting-row { display: block; width: 100%; }
}