/* ========================================================================
   base.css - Design System, Layout, Overlays, Print for Document Browser
   ======================================================================== */

/* ========================================================================
   CSS VARIABLES / DESIGN SYSTEM
   ======================================================================== */
:root {
    /* Primary palette (muted blue) */
    --primary: #4a6da7;
    --primary-dark: #3b5998;
    --primary-light: #dce4f0;
    --primary-bg: #f2f5fa;

    /* Semantic colors (desaturated) */
    --success: #3d8b6e;
    --success-dark: #2d6b54;
    --success-light: #dceee6;

    --warning: #c4933f;
    --warning-dark: #a57a2e;
    --warning-light: #f5ead4;

    --danger: #b85450;
    --danger-dark: #9a3f3c;
    --danger-light: #f0d8d7;

    --info: #6b8db5;
    --info-light: #dfe8f2;

    /* Grays */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Layout */
    --container-max: 1600px;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-size-xs: 10px;
    --font-size-sm: 11px;
    --font-size-base: 13px;
    --font-size-md: 14px;
    --font-size-lg: 16px;
    --font-size-xl: 20px;

    /* Transitions */
    --transition: all 0.15s ease;
}

/* ========================================================================
   BASE STYLES
   ======================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.4;
    font-size: var(--font-size-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ========================================================================
   HEADER
   ======================================================================== */
.dashboard-header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.header-title-group {
    display: flex;
    flex-direction: column;
}

.header-title-group h1 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.3px;
}

.report-meta {
    font-size: var(--font-size-xs);
    color: var(--gray-500);
    margin-top: 2px;
}

.report-meta .client-code {
    font-weight: 600;
    color: var(--primary);
}

.header-actions {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

/* ========================================================================
   BUTTONS
   ======================================================================== */
.btn {
    padding: 5px 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 0;
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition);
    white-space: nowrap;
    font-family: var(--font-family);
}

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

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-sm {
    padding: 3px 8px;
    font-size: var(--font-size-xs);
}

/* ========================================================================
   FOOTER
   ======================================================================== */
.dashboard-footer {
    background: white;
    border: 1px solid var(--gray-200);
    padding: 4px 12px;
    font-size: var(--font-size-xs);
    color: var(--gray-500);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    margin-top: 8px;
}

/* ========================================================================
   LOADING OVERLAY
   ======================================================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 16px;
    font-size: var(--font-size-md);
    color: var(--gray-600);
    font-weight: 500;
}

.loading-subtext {
    margin-top: 4px;
    font-size: var(--font-size-sm);
    color: var(--gray-400);
}

/* ========================================================================
   SESSION EXPIRED MODAL
   ======================================================================== */
.session-expired-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.session-expired-modal.active {
    display: flex;
}

.session-expired-content {
    background: white;
    padding: 32px 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 1px solid var(--gray-200);
}

.session-expired-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    background: var(--warning-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.session-expired-content h2 {
    font-size: 18px;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.session-expired-content p {
    font-size: var(--font-size-base);
    color: var(--gray-500);
    line-height: 1.5;
}

/* ========================================================================
   TOAST NOTIFICATIONS
   ======================================================================== */
.toast-container {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
}

.toast {
    padding: 8px 14px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: white;
    pointer-events: auto;
    transform: translateX(120%);
    transition: transform 0.3s ease, opacity 0.3s ease;
    max-width: 340px;
}

.toast-show {
    transform: translateX(0);
}

.toast-hide {
    opacity: 0;
    transform: translateX(120%);
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning-dark); }
.toast-info { background: var(--primary); }

/* ========================================================================
   DEV MODE BANNER
   ======================================================================== */
.dev-banner {
    background: var(--warning-light);
    border: 1px solid var(--warning);
    color: var(--warning-dark);
    padding: 4px 12px;
    font-size: var(--font-size-sm);
    text-align: center;
    margin-bottom: 8px;
}

/* ========================================================================
   EMPTY STATE
   ======================================================================== */
.empty-state {
    padding: 40px 24px;
    text-align: center;
    color: var(--gray-500);
}

.empty-state-icon {
    font-size: 36px;
    margin-bottom: 8px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: var(--font-size-md);
    color: var(--gray-700);
    margin-bottom: 4px;
}

.empty-state p {
    font-size: var(--font-size-sm);
}

/* ========================================================================
   SCROLLBAR
   ======================================================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ========================================================================
   PRINT STYLES
   ======================================================================== */
@media print {
    body {
        background: white;
        font-size: 9px;
    }

    .no-print {
        display: none !important;
    }

    .container {
        padding: 0;
        max-width: none;
        height: auto;
    }

    .dashboard-header {
        border-bottom: 1px solid #ccc;
        padding: 4px 0;
        margin-bottom: 4px;
    }

    .header-title-group h1 {
        font-size: 14px;
    }

    .report-meta {
        font-size: 8px;
    }

    .panels-container {
        display: block !important;
        height: auto !important;
    }

    .panel-right {
        display: none !important;
    }

    .panel-left {
        width: 100% !important;
        border: none !important;
        overflow: visible !important;
        height: auto !important;
    }

    .panel-left-scroll {
        overflow: visible !important;
        height: auto !important;
    }

    .folder-header {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .doc-row {
        break-inside: avoid;
    }

    .loading-overlay,
    .toast-container {
        display: none !important;
    }

    .dashboard-footer {
        border-top: 1px solid #ccc;
        padding: 2px 0;
        margin-top: 4px;
    }
}

@media print and (orientation: landscape) {
    .doc-row { font-size: 9px !important; }
}

@media print and (orientation: portrait) {
    .doc-row { font-size: 8px !important; }
}

/* Demo notice */
#demo-banner {
    background: var(--primary-bg);
    border-bottom: 1px solid var(--primary-light);
    color: var(--gray-700);
    font-size: 12px;
    padding: 6px 14px;
}
/* The demo banner sits above the full-height container. */
.container { height: calc(100vh - 29px); }
