/* ==============================
   EDELAR · style.css
   ============================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0A1628;
    --bg2: #0F1E35;
    --surface: #142240;
    --surface2: #1a2d50;
    --border: rgba(255,255,255,0.08);
    --blue: #3B82F6;
    --blue-glow: rgba(59,130,246,0.3);
    --red: #EF4444;
    --red-glow: rgba(239,68,68,0.3);
    --green: #10B981;
    --green-glow: rgba(16,185,129,0.3);
    --yellow: #F59E0B;
    --text: #F1F5F9;
    --text2: #94A3B8;
    --text3: #64748B;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    min-height: 100dvh;
}

/* ---- PANTALLAS ---- */
.pantalla { display: none; min-height: 100dvh; flex-direction: column; }
.pantalla.activa { display: flex; animation: fadeIn 0.3s ease; }
.has-bnav { display: none; }
.has-bnav.activa { display: flex; flex-direction: column; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---- LOGIN ---- */
.login-bg {
    background: radial-gradient(ellipse at 50% 0%, #1a3a6b 0%, #0A1628 60%);
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.login-glow {
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(59,130,246,0.2) 0%, transparent 70%);
    top: -100px; left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.login-box {
    width: 100%; max-width: 380px;
    padding: 40px 28px;
    display: flex; flex-direction: column;
    align-items: center; gap: 32px;
    position: relative; z-index: 1;
}

.logo-wrap { text-align: center; }
.logo-icon { font-size: 64px; filter: drop-shadow(0 0 20px rgba(59,130,246,0.6)); animation: pulse-icon 2.5s ease-in-out infinite; }
@keyframes pulse-icon { 0%,100%{transform:scale(1)} 50%{transform:scale(1.08)} }
.logo-title { font-size: 42px; font-weight: 800; letter-spacing: 6px; background: linear-gradient(135deg,#60A5FA,#3B82F6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.logo-sub { color: var(--text2); font-size: 14px; margin-top: 6px; letter-spacing: 1px; }

.login-form { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.input-label { font-size: 13px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-icon { position: absolute; left: 16px; font-size: 18px; }
.input-wrap input {
    width: 100%; padding: 16px 16px 16px 48px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text);
    font-size: 16px; font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.input-wrap input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-glow); }
.input-wrap input::placeholder { color: var(--text3); }

.btn-primary {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 24px;
    background: linear-gradient(135deg, #3B82F6, #1D4ED8);
    border: none; border-radius: var(--radius);
    color: white; font-size: 16px; font-weight: 700;
    cursor: pointer; font-family: inherit;
    transition: all var(--transition);
    box-shadow: 0 4px 20px var(--blue-glow);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 30px var(--blue-glow); }
.btn-primary:active { transform: translateY(0); }
.login-ver { color: var(--text3); font-size: 12px; }

/* ---- TOPBAR ---- */
.topbar {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; z-index: 50;
    backdrop-filter: blur(12px);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-logo { font-size: 22px; filter: drop-shadow(0 0 8px rgba(59,130,246,0.5)); }
.topbar-title { display: block; font-size: 16px; font-weight: 700; color: var(--text); }
.topbar-sub { display: block; font-size: 11px; color: var(--text3); }

.user-badge { display: flex; align-items: center; gap: 8px; }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), #1D4ED8);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: white;
}

.back-btn {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text); font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
}
.back-btn:hover { background: var(--surface2); }

.badge-count {
    min-width: 28px; height: 28px; padding: 0 8px;
    border-radius: 14px; background: var(--blue);
    font-size: 13px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.badge-count.danger { background: var(--red); }

.icon-btn { background: none; border: none; font-size: 20px; cursor: pointer; padding: 4px; }

/* ---- PAGE CONTENT ---- */
.page-content { flex: 1; overflow-y: auto; padding: 20px; padding-bottom: 90px; }

/* ---- STATUS BANNER ---- */
.status-banner {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-radius: var(--radius-sm);
    background: var(--surface); border: 1px solid var(--border);
    margin-bottom: 20px; font-size: 14px; font-weight: 500;
}
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-green { background: var(--green); box-shadow: 0 0 8px var(--green-glow); animation: blink 2s ease infinite; }
.dot-red { background: var(--red); box-shadow: 0 0 8px var(--red-glow); animation: blink 1s ease infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ---- STATS ---- */
.stats-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 28px; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 16px 12px;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    transition: all var(--transition);
}
.stat-card:hover { border-color: var(--blue); transform: translateY(-2px); }
.stat-val { font-size: 28px; font-weight: 800; color: var(--blue); }
.stat-lbl { font-size: 10px; color: var(--text3); text-align: center; text-transform: uppercase; letter-spacing: 0.5px; }

/* ---- SECTION ---- */
.section-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 14px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.section-time { font-size: 12px; color: var(--text3); }

/* ---- MENU GRID ---- */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.btn-menu {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 16px;
    display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
    cursor: pointer; text-align: left; font-family: inherit;
    transition: all var(--transition);
}
.btn-menu:hover { border-color: var(--blue); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.btn-menu:active { transform: translateY(0); }
.btn-menu.full { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 16px; }
.menu-icon { font-size: 28px; padding: 10px; border-radius: var(--radius-sm); }
.menu-lbl { font-size: 15px; font-weight: 700; color: var(--text); }
.menu-desc { font-size: 12px; color: var(--text3); }

/* ---- BOTTOM NAV ---- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg2); border-top: 1px solid var(--border);
    display: flex; z-index: 50; padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
    flex: 1; background: none; border: none; color: var(--text3);
    padding: 10px 4px; font-size: 10px; font-family: inherit;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    cursor: pointer; transition: color var(--transition); font-weight: 500;
}
.nav-item span:first-child { font-size: 20px; }
.nav-item.active { color: var(--blue); }
.nav-item:hover { color: var(--text); }

/* ---- TRABAJADORES ---- */
.worker-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 20px;
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 12px; transition: all var(--transition);
}
.worker-card:hover { border-color: rgba(255,255,255,0.15); }
.worker-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700; flex-shrink: 0;
}
.worker-info { flex: 1; }
.worker-name { font-size: 15px; font-weight: 600; color: var(--text); }
.worker-role { font-size: 12px; color: var(--text3); margin-top: 2px; }
.worker-status { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px; }
.status-active { background: rgba(16,185,129,0.15); color: var(--green); }
.status-inactive { background: rgba(100,116,139,0.2); color: var(--text3); }

/* ---- SWITCH ---- */
.switch { position: relative; display: inline-block; width: 46px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--surface2); border-radius: 24px;
    transition: var(--transition); border: 1px solid var(--border);
}
.slider::before {
    position: absolute; content: "";
    height: 18px; width: 18px; left: 3px; bottom: 2px;
    background: var(--text2); border-radius: 50%;
    transition: var(--transition);
}
input:checked + .slider { background: rgba(16,185,129,0.2); border-color: var(--green); }
input:checked + .slider::before { transform: translateX(21px); background: var(--green); }

/* ---- FALLAS ---- */
.falla-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px;
    margin-bottom: 14px; transition: all var(--transition);
}
.falla-card.activa { border-color: var(--red); background: rgba(239,68,68,0.05); }
.falla-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.falla-info { flex: 1; }
.falla-num { font-size: 11px; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.falla-title { font-size: 15px; font-weight: 600; color: var(--text); }
.falla-desc { font-size: 13px; color: var(--text3); margin-top: 4px; }
.falla-tag { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 20px; letter-spacing: 0.5px; }
.tag-ok { background: rgba(16,185,129,0.15); color: var(--green); }
.tag-alerta { background: rgba(239,68,68,0.15); color: var(--red); animation: blink 1.5s ease infinite; }

.falla-switch-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.falla-switch-label { font-size: 13px; color: var(--text2); flex: 1; }
.falla-sw input:checked + .slider { background: rgba(239,68,68,0.2); border-color: var(--red); }
.falla-sw input:checked + .slider::before { transform: translateX(21px); background: var(--red); }

.btn-camara {
    display: flex; align-items: center; gap: 6px;
    margin-top: 12px; padding: 8px 14px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text2);
    font-size: 13px; font-weight: 500; cursor: pointer;
    font-family: inherit; transition: all var(--transition);
}
.btn-camara:hover { border-color: var(--blue); color: var(--text); }
.btn-camara.foto-ok { border-color: var(--green); color: var(--green); background: rgba(16,185,129,0.08); }

/* ---- ALERT BANNER ---- */
.alert-banner {
    display: flex; align-items: center; gap: 10px;
    background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--radius-sm); padding: 12px 16px;
    margin-bottom: 16px; font-size: 14px; font-weight: 600; color: var(--red);
    animation: blink 2s ease infinite;
}
.alert-banner.hidden { display: none; }

/* ---- HISTORIAL ---- */
.hist-card {
    background: var(--surface); border-left: 3px solid var(--green);
    border-radius: var(--radius); padding: 16px 18px;
    margin-bottom: 12px; border-top: 1px solid var(--border);
    border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
    animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }
.hist-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.hist-badge { font-size: 11px; font-weight: 700; color: var(--green); background: rgba(16,185,129,0.12); padding: 3px 8px; border-radius: 20px; }
.hist-title { font-size: 14px; font-weight: 600; color: var(--text); }
.hist-meta { font-size: 12px; color: var(--text3); }

/* ---- EMPTY STATE ---- */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 52px; margin-bottom: 16px; opacity: 0.5; }
.empty-title { font-size: 17px; font-weight: 600; color: var(--text2); margin-bottom: 8px; }
.empty-sub { font-size: 14px; color: var(--text3); max-width: 260px; margin: 0 auto; }

/* ---- TOAST ---- */
.toast {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); padding: 12px 24px; border-radius: 40px;
    font-size: 14px; font-weight: 600;
    opacity: 0; pointer-events: none; z-index: 200;
    transition: all 0.3s ease; white-space: nowrap;
    box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }

/* ---- MODAL ---- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 100; backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal-box {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 24px 24px 0 0; padding: 32px 24px 40px;
    width: 100%; max-width: 480px; text-align: center;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-icon { font-size: 44px; margin-bottom: 12px; }
.modal-box h3 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.modal-box p { color: var(--text2); font-size: 14px; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; }
.modal-btn { flex: 1; padding: 14px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit; border: none; transition: all var(--transition); }
.modal-btn.cancel { background: var(--surface2); color: var(--text2); }
.modal-btn.confirm { background: linear-gradient(135deg, var(--red), #B91C1C); color: white; }
.modal-btn.confirm.safe { background: linear-gradient(135deg, var(--green), #065F46); }
