/**
 * SecretarIA Legal - Dashboard Styles
 *
 * @file        dashboard.css
 * @description Dashboard-specific layout and styling
 * @author      Mauricio Moreno Vásquez
 * @version     2.0.0
 *
 * This file handles:
 * - Dashboard page layout (wider than calculator pages)
 * - Header customization with user menu
 * - Welcome section styling
 * - Dashboard section spacing and typography
 * - Responsive design for mobile/tablet
 * - Loading and auth gate states
 * - Print styles
 *
 * Dependencies:
 * - design-system.css (CSS variables)
 * - components.css (base component styles)
 * - dashboard.js (injects component-specific styles dynamically)
 *
 * Note: Dashboard.js injects ~400 lines of component styles.
 * This file focuses on page layout, not component styling.
 */

/* ============================================
   1. MAIN CONTAINER OVERRIDE
   ============================================ */

/**
 * Override .main-container width for dashboard
 * Calculator pages use 650px max-width
 * Dashboard needs 1000px to accommodate stats grid and tool cards
 */
.main-container {
    max-width: 1000px !important;
    margin: 40px auto;
    padding: 0 20px;
}

/* ============================================
   2. HEADER CUSTOMIZATION
   ============================================ */

/**
 * Dashboard header with centered content
 * Contains logo and user menu
 */
.page-header {
    display: flex;
    justify-content: center;
    align-items: center;
}

/**
 * Header content wrapper
 * Constrains header width to match main container
 */
.dashboard-header-content {
    width: 100%;
    max-width: 1000px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
}

/**
 * User menu container
 * Shows user greeting and logout button
 */
.dashboard-user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--light-text-color, #f8f9fa);
}

/**
 * User greeting text
 * Shows "Hola, [Nombre]" from Supabase metadata
 */
#user-greeting {
    font-size: 0.95em;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/**
 * Logout button
 * Gold accent color matching brand
 */
.logout-button {
    background: rgba(255, 193, 7, 0.15);
    color: var(--accent-color, #FFC107);
    border: 1px solid var(--accent-color, #FFC107);
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
}

.logout-button:hover {
    background: var(--accent-color, #FFC107);
    color: var(--primary-color, #0D47A1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

.logout-button:active {
    transform: translateY(0);
}

/* ============================================
   3. WELCOME SECTION
   ============================================ */

/**
 * Welcome section
 * Shows personalized greeting at top of dashboard
 */
.dashboard-welcome {
    padding: 30px 0 20px 0;
    text-align: center;
}

.dashboard-welcome h1 {
    font-size: 1.8em;
    font-weight: 600;
    color: var(--primary-color, #0D47A1);
    margin: 0 0 10px 0;
}

/* ============================================
   4. DASHBOARD SECTIONS
   ============================================ */

/**
 * Dashboard sections
 * Containers for stats, tools, deadlines, activity
 */
.dashboard-section {
    margin-bottom: 50px;
}

/**
 * Section headings
 * H2 with accent color bottom border
 */
.dashboard-section h2 {
    font-size: 1.4em;
    font-weight: 600;
    color: var(--primary-color, #0D47A1);
    margin: 0 0 25px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent-color, #FFC107);
}

/* ============================================
   5. LOADING & AUTH STATES
   ============================================ */

/**
 * Loading state
 * Shown while dashboard data is loading
 */
.dashboard-loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-color, #333);
}

.dashboard-loading .spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 20px auto;
    border: 4px solid var(--bg-color, #f4f7f9);
    border-top: 4px solid var(--primary-color, #0D47A1);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/**
 * Not authenticated state
 * Shown when user is not logged in
 */
.dashboard-not-authenticated {
    text-align: center;
    padding: 60px 20px;
}

/**
 * Auth gate overlay
 * Semi-transparent overlay prompting login
 */
.auth-gate-overlay {
    background: rgba(13, 71, 161, 0.05);
    border: 2px solid var(--primary-color, #0D47A1);
    border-radius: 12px;
    padding: 40px 30px;
    text-align: center;
    max-width: 500px;
    margin: 40px auto;
}

.auth-gate-overlay h3 {
    color: var(--primary-color, #0D47A1);
    margin-bottom: 15px;
    font-size: 1.3em;
}

.auth-gate-overlay p {
    color: var(--text-color, #333);
    margin-bottom: 25px;
    line-height: 1.6;
}

/* ============================================
   6. RESPONSIVE DESIGN
   ============================================ */

/**
 * Tablet breakpoint (768px)
 * Stacks header, reduces spacing
 */
@media (max-width: 768px) {
    /* Main container adjustments */
    .main-container {
        max-width: 100% !important;
        padding: 0 15px;
        margin: 30px auto;
    }

    /* Header stacking */
    .dashboard-header-content {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    /* User menu full width */
    .dashboard-user-menu {
        width: 100%;
        justify-content: space-between;
    }

    /* Welcome section */
    .dashboard-welcome {
        padding: 20px 0 15px 0;
    }

    .dashboard-welcome h1 {
        font-size: 1.5em;
    }

    /* Section headings */
    .dashboard-section {
        margin-bottom: 40px;
    }

    .dashboard-section h2 {
        font-size: 1.25em;
        margin-bottom: 20px;
    }

    /* Auth gate overlay */
    .auth-gate-overlay {
        padding: 30px 20px;
        margin: 30px auto;
    }

    .auth-gate-overlay h3 {
        font-size: 1.2em;
    }
}

/**
 * Mobile landscape breakpoint (600px)
 * Further spacing reductions
 */
@media (max-width: 600px) {
    .dashboard-section {
        margin-bottom: 35px;
    }

    .dashboard-section h2 {
        font-size: 1.2em;
        margin-bottom: 18px;
        padding-bottom: 8px;
    }

    .logout-button {
        padding: 7px 14px;
        font-size: 0.85em;
    }
}

/**
 * Mobile portrait breakpoint (480px)
 * Full mobile optimization
 */
@media (max-width: 480px) {
    /* Container adjustments */
    .main-container {
        padding: 0 12px;
        margin: 20px auto;
    }

    /* Header */
    .dashboard-header-content {
        padding: 12px;
        gap: 12px;
    }

    /* User menu stacking */
    .dashboard-user-menu {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    #user-greeting {
        font-size: 0.9em;
        text-align: center;
        width: 100%;
    }

    .logout-button {
        width: 100%;
        text-align: center;
        padding: 10px 16px;
    }

    /* Welcome section */
    .dashboard-welcome {
        padding: 15px 0 10px 0;
    }

    .dashboard-welcome h1 {
        font-size: 1.3em;
    }

    /* Sections */
    .dashboard-section {
        margin-bottom: 30px;
    }

    .dashboard-section h2 {
        font-size: 1.1em;
        margin-bottom: 15px;
        padding-bottom: 6px;
    }

    /* Auth gate */
    .auth-gate-overlay {
        padding: 25px 15px;
        margin: 20px auto;
    }

    .auth-gate-overlay h3 {
        font-size: 1.1em;
        margin-bottom: 12px;
    }

    .auth-gate-overlay p {
        font-size: 0.95em;
        margin-bottom: 20px;
    }
}

/* ============================================
   7. PRINT STYLES
   ============================================ */

/**
 * Print optimization
 * Hides interactive elements
 */
@media print {
    .page-header,
    footer,
    .logout-button,
    .dashboard-user-menu {
        display: none !important;
    }

    .main-container {
        max-width: 100% !important;
        margin: 0;
        padding: 0;
    }

    .dashboard-section {
        page-break-inside: avoid;
        margin-bottom: 20px;
    }

    .dashboard-section h2 {
        border-bottom-color: #000;
    }

    /* Hide dynamic content that may not render well */
    .dashboard-loading,
    .auth-gate-overlay {
        display: none !important;
    }
}

/* ============================================
   8. ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/**
 * Focus states for keyboard navigation
 */
.logout-button:focus {
    outline: 2px solid var(--accent-color, #FFC107);
    outline-offset: 2px;
}

/**
 * Reduced motion support
 */
@media (prefers-reduced-motion: reduce) {
    .logout-button,
    .dashboard-loading .spinner {
        animation: none;
        transition: none;
    }

    .logout-button:hover {
        transform: none;
    }
}

/**
 * High contrast mode support
 */
@media (prefers-contrast: high) {
    .logout-button {
        border-width: 2px;
    }

    .dashboard-section h2 {
        border-bottom-width: 3px;
    }
}

/* ============================================
   9. UTILITY CLASSES
   ============================================ */

/**
 * Hidden utility
 * Hides element while maintaining accessibility
 */
.dashboard-hidden {
    display: none !important;
}

/**
 * Visually hidden (screen reader only)
 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
