/* ============================================================
   Facilityfree - Módulo Asistencia
   Estilos compartidos
   ============================================================ */

:root {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface2: #1c1c1c;
    --surface3: #242424;
    --border: rgba(255,255,255,.10);
    --border2: rgba(255,255,255,.16);
    --text: #f0f0f0;
    --text2: #999999;
    --text3: #666666;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #3498db;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============ LAYOUT PRINCIPAL ============ */
.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 0 24px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.sidebar-brand h1 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.sidebar-brand span {
    font-size: 11px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: block;
    margin-top: 2px;
}

.erp-back-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #f0f0f0;
}

.erp-back-link:hover { opacity: 0.8; }

.erp-back-link svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    stroke: currentColor;
    color: #f0f0f0;
}

.erp-back-link img {
    height: 52px;
    width: auto;
    display: block;
}

.sidebar-section { padding: 8px 12px; }

.sidebar-label {
    font-size: 10px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 8px 12px;
    font-weight: 500;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text2);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    margin-bottom: 2px;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }

.nav-item.active {
    background: var(--surface3);
    color: var(--text);
    font-weight: 500;
}

.nav-item .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text3);
}

.nav-item.active .dot { background: var(--success); }

.user-panel {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.user-info { display: flex; align-items: center; gap: 10px; }

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
}

.user-name { font-size: 12px; font-weight: 500; }
.user-role { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; }

.logout-link {
    display: block;
    margin-top: 12px;
    font-size: 11px;
    color: var(--text3);
    text-decoration: none;
    cursor: pointer;
}
.logout-link:hover { color: var(--danger); }

/* ============ MAIN ============ */
.main {
    padding: 32px 40px;
    max-width: 1400px;
}

.main-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 12px;
}

.main-title {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.main-subtitle {
    color: var(--text2);
    font-size: 13px;
    margin-bottom: 32px;
}

.main-timestamp {
    font-size: 12px;
    color: var(--text3);
    font-feature-settings: 'tnum';
}

.live-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    margin-right: 6px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ============ KPIS ============ */
.kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.kpi-label {
    font-size: 11px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1;
    font-feature-settings: 'tnum';
}

.kpi-unit { font-size: 14px; color: var(--text2); font-weight: 400; margin-left: 4px; }

.kpi-delta { font-size: 11px; color: var(--text3); margin-top: 6px; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

/* ============ CARD ============ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 24px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.card-title { font-size: 13px; font-weight: 600; color: var(--text); }
.card-subtitle { font-size: 11px; color: var(--text3); margin-top: 2px; }
.card-body { padding: 20px; }

/* ============ BOTONES ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid var(--border2);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn:hover { background: var(--surface2); }

.btn-primary {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
    font-weight: 600;
}
.btn-primary:hover { background: #ffffff; }

.btn-danger {
    background: var(--danger);
    color: var(--text);
    border-color: var(--danger);
    font-weight: 600;
}

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ TABLA ============ */
.tabla-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.tabla th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
}

.tabla td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.tabla tr:last-child td { border-bottom: none; }
.tabla tr:hover { background: var(--surface2); }

/* ============ BADGES ============ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge.success { background: rgba(46, 204, 113, 0.12); color: var(--success); }
.badge.warning { background: rgba(243, 156, 18, 0.12); color: var(--warning); }
.badge.danger { background: rgba(231, 76, 60, 0.12); color: var(--danger); }
.badge.info { background: rgba(52, 152, 219, 0.12); color: var(--info); }
.badge.default { background: var(--surface3); color: var(--text2); }

/* ============ FORMULARIOS ============ */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 11px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
    font-weight: 500;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: var(--surface2);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    transition: border 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--border2);
    background: var(--surface3);
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.form-help { color: var(--text3); font-size: 11px; margin-top: 4px; }

/* ============ MODAL ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title { font-size: 15px; font-weight: 600; }
.modal-close { background: transparent; border: none; color: var(--text3); cursor: pointer; font-size: 20px; padding: 0; }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ============ ALERTAS ============ */
.alert {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 2px solid var(--warning);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.alert-icon { font-size: 16px; line-height: 1; }
.alert.success { border-left-color: var(--success); }
.alert.danger { border-left-color: var(--danger); }
.alert.info { border-left-color: var(--info); }
.alert-text { color: var(--text); flex: 1; }

/* ============ LOADING ============ */
.loading {
    padding: 40px 20px;
    text-align: center;
    color: var(--text3);
    font-size: 13px;
}

.loading::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border2);
    border-top-color: var(--text);
    border-radius: 50%;
    margin-right: 10px;
    vertical-align: middle;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text3);
    font-size: 13px;
}

/* ============ LOGIN ============ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 32px;
    max-width: 400px;
    width: 100%;
}

.login-brand {
    text-align: center;
    margin-bottom: 24px;
}

.login-brand h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.login-brand span {
    font-size: 11px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; }
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .main { padding: 20px; }
}