/* frontend/css/style.css */
:root {
    --primary: #0f172a; 
    --primary-light: #1e293b;
    --accent: #2563eb; 
    --accent-hover: #1d4ed8;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --success: #10b981;
    --success-light: #d1fae5;
    --bg-color: #f8fafc;
    --surface: #ffffff;
    --text-main: #334155;
    --text-muted: #64748b;
    --border: #e2e8f0;
    
    --radius-lg: 12px;
    --radius-md: 8px;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Base de Enrutamiento de Area */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Menú Lateral (Desktop por Defecto) */
.sidebar {
    width: 280px;
    background-color: var(--primary);
    color: white;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header h2 { font-size: 1.25rem; font-weight: 800; margin-right: 12px; letter-spacing: -0.5px;}
.sidebar-header .badge { background: var(--accent); font-size: 0.65rem; padding: 3px 6px; border-radius: 4px; font-weight: bold;}
.close-sidebar-btn { display: none; background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; margin-left: auto;}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.nav-item i { margin-right: 14px; font-size: 1.15rem; width: 24px; text-align: center;}
.nav-item:hover, .nav-item.active { background-color: var(--primary-light); color: white; transform: translateX(2px); }
.nav-item.active { border-left: 4px solid var(--accent); background: linear-gradient(90deg, rgba(37,99,235,0.1) 0%, rgba(30,41,59,0) 100%);}

.alert-count {
    margin-left: auto; background: var(--danger); color: white; font-size: 0.75rem; 
    padding: 2px 8px; border-radius: 20px; font-weight: 700; box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.sidebar-footer {
    padding: 20px 24px; border-top: 1px solid rgba(255,255,255,0.05);
    display: flex; justify-content: space-between; align-items: center;
}

.user-info { display: flex; align-items: center; gap: 12px; }
.user-info img { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--primary-light);}
.user-info div { display: flex; flex-direction: column; }
.user-info strong { font-size: 0.9rem; color: white; }
.user-info span { font-size: 0.75rem; color: #64748b; }

.logout-btn { background: none; border: none; color: #64748b; cursor: pointer; transition: color 0.2s; font-size: 1.1rem;}
.logout-btn:hover { color: var(--danger); }

/* Main Wrapper */
.main-content {
    flex: 1; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;
}

/* Tiras Móviles Superior */
.mobile-header {
    display: none; background: var(--surface); padding: 18px 24px;
    align-items: center; justify-content: space-between;
    box-shadow: var(--shadow-sm); z-index: 40; position: sticky; top: 0;
}
.menu-toggle-btn { background: none; border: none; font-size: 1.5rem; color: var(--text-main); cursor: pointer;}
.mobile-header .brand { font-weight: 800; font-size: 1.3rem; color: var(--primary); letter-spacing: -0.5px;}
.notification-btn { position: relative; background: none; border:none; font-size: 1.5rem; color: var(--text-main); cursor: pointer;}
.dot { position: absolute; top: 2px; right: 2px; width: 10px; height: 10px; background: var(--danger); border-radius: 50%; border: 2px solid white;}

/* Cuerpo */
.content-wrapper { padding: 36px 40px; max-width: 1600px; margin: 0 auto; width: 100%;}

.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 36px; }
.page-header h1 { font-size: 1.9rem; font-weight: 800; color: var(--primary); margin-bottom: 6px; letter-spacing: -0.5px;}
.page-header p { color: var(--text-muted); font-size: 1rem; font-weight: 500;}

/* Botonería Gruesa Tactil PWA */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 12px 24px; border-radius: var(--radius-md); font-weight: 600; font-size: 0.95rem;
    cursor: pointer; border: none; transition: all 0.2s; font-family: inherit;
    box-shadow: var(--shadow-sm);
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 6px -1px rgba(37,99,235, 0.3);}
.btn-outline { background: white; border: 1px solid var(--border); color: var(--text-main); }
.btn-outline:hover { background: var(--bg-color); }
.quick-actions { display: flex; gap: 16px; }

/* Dashboard Cards Geo */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; margin-bottom: 40px;}
.kpi-card { background: var(--surface); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-sm); display: flex; gap: 24px; border: 1px solid rgba(0,0,0,0.03);}
.kpi-icon { width: 64px; height: 64px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; }
.kpi-icon.blue { background: #eff6ff; color: #2563eb; }
.kpi-icon.red { background: var(--danger-light); color: var(--danger); box-shadow: 0 0 15px rgba(239,68,68,0.2);}
.kpi-icon.green { background: var(--success-light); color: #059669; }

.kpi-data { display: flex; flex-direction: column; justify-content: center;}
.kpi-data h3 { font-size: 0.95rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;}
.kpi-data h2 { font-size: 2.2rem; color: var(--primary); font-weight: 800; line-height: 1.2; margin-bottom: 4px;}
.trend { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); display:flex; align-items:center; gap: 6px;}
.trend.positive { color: #059669; }
.trend.negative { color: var(--danger); }

/* Superficie de Datos */
.panel { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid rgba(0,0,0,0.03); overflow: hidden; margin-bottom: 24px;}
.panel-header { padding: 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center;}
.panel-header h2 { font-size: 1.3rem; font-weight: 700; color: var(--primary); letter-spacing:-0.3px;}
.form-control { padding: 12px 20px; border: 1px solid var(--border); border-radius: var(--radius-md); font-family: inherit; font-size: 0.95rem; outline: none; transition: border-color 0.2s;}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);}

.table-responsive { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th { background: #f8fafc; padding: 16px 24px; font-size: 0.8rem; text-transform: uppercase; font-weight: 700; color: #475569; letter-spacing: 0.5px;}
.data-table td { padding: 20px 24px; border-bottom: 1px solid var(--border); vertical-align: middle; color: #1e293b; font-weight: 500;}
.td-user { display: inline-flex; align-items: center; gap: 16px; }
.avatar { width: 44px; height: 44px; background: #e2e8f0; color: #334155; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem;}
.td-user div { display: flex; flex-direction: column; }
.td-user strong { color: var(--primary); font-weight: 700; font-size:1rem;}
.td-user span { font-size: 0.8rem; color: var(--text-muted); }

.badge-status { padding: 6px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; display: inline-flex; align-items: center; gap: 6px;}
.badge-status.success { background: var(--success-light); color: #047857; }
.badge-status.danger { background: var(--danger-light); color: #b91c1c; }

.btn-icon { background: var(--bg-color); border: 1px solid var(--border); border-radius: 6px; font-size: 1.1rem; color: var(--text-muted); cursor: pointer; padding: 8px 12px; transition: all 0.2s; margin-right: 4px;}
.btn-icon:hover { color: var(--primary); background: #e2e8f0;}
.text-red:hover { color: var(--surface); background: var(--danger); border-color: var(--danger);}

/* 
=================== PWA RULES PARA RESPONSIVE (UX OBLIGATORIO) ===================
Prioriza claridad y táctil ancho para la pantalla de móvil.
*/
@media (max-width: 1024px) {
    .content-wrapper { padding: 24px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .close-sidebar-btn { display: block; }
    
    .mobile-header { display: flex; }
    .content-wrapper { padding: 20px; }
    
    .page-header { flex-direction: column; align-items: flex-start; gap: 20px; }
    .quick-actions { width: 100%; flex-direction: column;}
    .btn { width: 100%; padding: 16px; font-size: 1rem;} 
    
    .kpi-grid { grid-template-columns: 1fr; gap: 16px;}
    .panel-header { flex-direction: column; align-items: flex-start; gap: 16px; }
    .filters { width: 100%; }
    .filter-input { width: 100%; padding: 14px;}
    
    /* Adaptación Tabla a Cards Mobile */
    .data-table thead { display: none; }
    .data-table td { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--bg-color); font-size:0.9rem;}
    .data-table td::before { content: attr(data-label); font-weight: 700; text-transform: uppercase; font-size: 0.75rem; color: var(--text-muted); }
    .data-table tr { display: block; border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 16px; box-shadow: var(--shadow-sm);}
    .td-user { text-align: right; width: auto; justify-content: flex-end;}
}
