/* ═══════════════════════════════════════
   BERICONS SST - STYLES.CSS
   Diseño: Apple HIG Inspired
   Mobile-first • Responsive • PWA Ready
   ═══════════════════════════════════════ */

/* ────────────────────────────────────────
   CSS Variables (Design Tokens)
   ──────────────────────────────────────── */
:root {
    /* Colores SST */
    --color-emergency: #DC2626;
    --color-warning: #FF5722;
    --color-info: #2563EB;
    --color-success: #16A34A;
    
    /* Grises Apple-style */
    --color-bg: #F5F5F7;
    --color-surface: #FFFFFF;
    --color-text-primary: #1D1D1F;
    --color-text-secondary: #6E6E73;
    --color-border: #D2D2D7;
    
    /* Espaciado */
    --space-xs: 8px;
    --space-sm: 12px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    
    /* Tipografía Apple-style */
    --font-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-base: 16px;
    --font-size-lg: 20px;
    --font-size-xl: 28px;
    --font-size-2xl: 34px;
    
    /* Bordes y sombras */
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.12);
    
    /* Transiciones */
    --transition-fast: 0.2s ease;
    --transition-base: 0.3s ease;
}

/* ────────────────────────────────────────
   Reset & Base Styles
   ──────────────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-system);
    font-size: var(--font-size-base);
    color: var(--color-text-primary);
    background-color: var(--color-bg);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ────────────────────────────────────────
   Layout
   ──────────────────────────────────────── */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 var(--space-md);
    width: 100%;
}

.main-content {
    flex: 1;
    padding-top: var(--space-md);
    padding-bottom: var(--space-xl);
}

/* ────────────────────────────────────────
   Header
   ──────────────────────────────────────── */
.header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-md) 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.8);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo h1 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text-primary);
}

.user-badge {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-warning), var(--color-emergency));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.user-badge:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* ────────────────────────────────────────
   Welcome Section
   ──────────────────────────────────────── */
.welcome-section {
    text-align: center;
    padding: var(--space-xl) 0 var(--space-lg);
}

.welcome-section h2 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-bottom: var(--space-xs);
    color: var(--color-text-primary);
}

.subtitle {
    font-size: var(--font-size-base);
    color: var(--color-text-secondary);
    font-weight: 400;
}

/* ────────────────────────────────────────
   Action Buttons (Estilo Apple List)
   ──────────────────────────────────────── */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
}

.action-btn {
    background: var(--color-surface);
    border: none;
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    transition: width var(--transition-base);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Emergency Button */
.emergency-btn {
    border-left: 4px solid var(--color-emergency);
}

.emergency-btn .btn-icon {
    color: var(--color-emergency);
}

.emergency-btn::before {
    background: var(--color-emergency);
}

.emergency-btn:hover::before {
    width: 100%;
    opacity: 0.05;
}

/* Incident Button */
.incident-btn {
    border-left: 4px solid var(--color-warning);
}

.incident-btn .btn-icon {
    color: var(--color-warning);
}

.incident-btn::before {
    background: var(--color-warning);
}

.incident-btn:hover::before {
    width: 100%;
    opacity: 0.05;
}

/* Reports Button */
.reports-btn {
    border-left: 4px solid var(--color-info);
}

.reports-btn .btn-icon {
    color: var(--color-info);
}

.reports-btn::before {
    background: var(--color-info);
}

.reports-btn:hover::before {
    width: 100%;
    opacity: 0.05;
}

/* Button Components */
.btn-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-content {
    flex: 1;
}

.btn-content h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--color-text-primary);
}

.btn-content p {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    line-height: 1.4;
}

.btn-arrow {
    font-size: 28px;
    color: var(--color-text-secondary);
    font-weight: 300;
}

/* ────────────────────────────────────────
   Quick Stats
   ──────────────────────────────────────── */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-value {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ────────────────────────────────────────
   Info Banner
   ──────────────────────────────────────── */
.info-banner {
    background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    border: 1px solid #BFDBFE;
}

.banner-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.banner-content strong {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    margin-bottom: 2px;
}

.banner-content p {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin: 0;
}

/* ────────────────────────────────────────
   Footer
   ──────────────────────────────────────── */
.footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: var(--space-lg) 0;
    margin-top: auto;
}

.footer-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    text-align: center;
    margin-bottom: var(--space-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

#statusIndicator {
    color: var(--color-success);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.footer-legal {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    text-align: center;
}

/* ────────────────────────────────────────
   Offline Banner
   ──────────────────────────────────────── */
.offline-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-warning);
    color: white;
    padding: var(--space-sm);
    text-align: center;
    font-size: var(--font-size-sm);
    font-weight: 600;
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* ────────────────────────────────────────
   Loading Overlay
   ──────────────────────────────────────── */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    color: white;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: var(--space-md);
}

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

.loading-overlay p {
    font-size: var(--font-size-base);
    font-weight: 500;
}

/* ────────────────────────────────────────
   Responsive Design
   ──────────────────────────────────────── */

/* Tablets (landscape) */
@media (min-width: 768px) {
    .container {
        padding: 0 var(--space-xl);
    }
    
    .action-btn {
        padding: var(--space-xl);
    }
    
    .quick-stats {
        gap: var(--space-md);
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .welcome-section h2 {
        font-size: 42px;
    }
    
    .action-btn:hover {
        transform: translateY(-4px);
    }
}

/* Modo Oscuro (respeta preferencias del sistema) */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #000000;
        --color-surface: #1C1C1E;
        --color-text-primary: #FFFFFF;
        --color-text-secondary: #98989D;
        --color-border: #38383A;
    }
    
    .header {
        background: rgba(28, 28, 30, 0.8);
    }
    
    .info-banner {
        background: linear-gradient(135deg, #1E3A5F 0%, #2C5282 100%);
        border-color: #3B5A7D;
    }
}

/* Accesibilidad - Mayor contraste */
@media (prefers-contrast: high) {
    .action-btn {
        border-width: 2px;
    }
    
    .stat-card,
    .info-banner {
        border: 2px solid var(--color-border);
    }
}

/* Reducir movimiento para usuarios sensibles */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Touch targets mínimos de 44x44px (Apple HIG) */
@media (pointer: coarse) {
    .action-btn {
        min-height: 88px;
    }
    
    .user-badge {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ════════════════════════════════════════
   Dashboard Button
   ════════════════════════════════════════ */
.action-btn.dashboard-btn {
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
}

.action-btn.dashboard-btn:hover {
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    transform: translateY(-2px);
}

.action-btn.dashboard-btn:active {
    transform: translateY(0);
}

.action-btn.dashboard-btn .btn-icon svg {
    color: white;
}

.action-btn.dashboard-btn .btn-content h3 {
    color: white;
}

.action-btn.dashboard-btn .btn-content p {
    color: rgba(255, 255, 255, 0.9);
}

.action-btn.dashboard-btn .btn-arrow {
    color: white;
}
.nav-link {
    padding: 8px 16px;
    color: #374151;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-link:hover {
    background: #F3F4F6;
    color: #2563EB;
}

.nav-link.admin-only {
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    color: white;
}

.nav-link.admin-only:hover {
    background: linear-gradient(135deg, #2563EB 0%, #1E40AF 100%);
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}
/* Header simplificado */
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #6B7280;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10B981;
}

/* ───────────────────────────────────────
   Professional Navbar
   ─────────────────────────────────────── */
.navbar {
    background: white;
    border-bottom: 1px solid #E5E7EB;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #1F2937;
    font-weight: 700;
    font-size: 20px;
}

.brand-icon {
    font-size: 24px;
}

.brand-highlight {
    color: #FF5722;
}

.nav-menu {
    display: flex;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    color: #6B7280;
    font-weight: 500;
    transition: all 0.2s;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
}

.nav-link:hover {
    background: #F3F4F6;
    color: #1F2937;
}

.nav-link.active {
    background: #FEF2F2;
    color: #DC2626;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #DC2626;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-initial {
    color: white;
    font-weight: 700;
    font-size: 16px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: #1F2937;
}

.user-role {
    font-size: 12px;
    color: #6B7280;
}

@media (max-width: 768px) {
    .nav-container {
        padding: 0 16px;
    }

    .user-details {
        display: none;
    }

    .nav-link span {
        display: none;
    }
}

/* ═══════════════════════════════════════
   HEADER ESTANDARIZADO
   ═══════════════════════════════════════ */

.page-header {
    padding: 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-4px);
}

.page-title {
    color: white;
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    text-align: center;
    flex: 1;
}

.page-header .user-badge {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.page-header .user-initial {
    font-weight: 700;
    font-size: 18px;
    color: #1F2937;
}

/* Responsive Header */
@media (max-width: 768px) {
    .page-title {
        font-size: 18px;
    }

    .back-btn {
        padding: 8px 12px;
        font-size: 14px;
    }

    .page-header .user-badge {
        width: 36px;
        height: 36px;
    }

    .page-header .user-initial {
        font-size: 14px;
    }

    .header-container {
        padding: 12px 16px;
    }
}
/* ────────────────────────────────────────
   🔧 FIX: Transición suave para avatar
   ──────────────────────────────────────── */
.user-avatar,
#userAvatar,
.user-initial {
    /* Transición suave cuando aparece */
    transition: opacity 0.3s ease;
}

/* El avatar se muestra normalmente - JavaScript controla contenido */
