:root {
    --bg-dark: #0f172a;
    --panel-glass: rgba(30, 41, 59, 0.7);
    --brand-accent: #10b981;
    --brand-accent-hover: #059669;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    
    /* Variables de tipografía y espaciado fluido (Responsive sin Media Queries excesivos) */
    --spacing-panel: clamp(1.5rem, 5vw, 3rem);
    --font-h1: clamp(1.5rem, 4vw, 2rem);
    --font-h2: clamp(1.25rem, 3vw, 1.75rem);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', system-ui, sans-serif; }

body.staff-layout { 
    background: var(--bg-dark); 
    color: var(--text-primary); 
    min-height: 100dvh; /* 'dvh' previene saltos por la barra de navegación móvil en iOS/Android */
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Authentication Screens */
.auth-wrapper { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    min-height: 100dvh; 
    padding: clamp(1rem, 5vw, 2rem); /* Padding dinámico que evita colisión en móviles pequeños */
}

.glass-panel { 
    background: var(--panel-glass); 
    padding: var(--spacing-panel); 
    border-radius: 12px; 
    border: 1px solid rgba(255,255,255,0.1); 
    width: 100%; 
    max-width: 420px; 
    backdrop-filter: blur(10px); 
    -webkit-backdrop-filter: blur(10px); /* Soporte crítico para WebKit (iOS) */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.glass-panel-wide { max-width: 550px; }

.brand-header { text-align: center; margin-bottom: 2rem; }
.brand-header h2 { color: var(--brand-accent); font-size: var(--font-h2); }
.brand-header p { color: var(--text-muted); font-size: clamp(0.875rem, 2vw, 1rem); margin-top: 0.25rem; }

/* Forms */
.form-group { margin-bottom: 1.5rem; width: 100%; }
.form-group label { display: block; margin-bottom: 0.5rem; font-size: 0.875rem; color: var(--text-muted); font-weight: 500; }
.form-group input { 
    width: 100%; 
    padding: 0.875rem; 
    background: #1e293b; 
    border: 1px solid #334155; 
    border-radius: 8px; 
    color: white; 
    outline: none; 
    transition: all 0.3s ease; 
    font-size: 16px; /* Evita el zoom automático en inputs de iOS Safari */
}
.form-group input:focus { 
    border-color: var(--brand-accent); 
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); 
}

/* Buttons */
.btn-primary { 
    width: 100%; 
    padding: 1rem; 
    background: var(--brand-accent); 
    border: none; 
    border-radius: 8px; 
    color: white; 
    font-weight: 600; 
    font-size: 1rem;
    cursor: pointer; 
    transition: background-color 0.2s ease, transform 0.1s ease;
}
.btn-primary:hover:not(:disabled) { background: var(--brand-accent-hover); transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-danger { 
    background: #ef4444; 
    color: white; 
    border: none; 
    padding: 0.6rem 1.2rem; 
    border-radius: 6px; 
    cursor: pointer; 
    transition: background 0.2s; 
    font-size: 0.875rem; 
    white-space: nowrap; 
}
.btn-danger:hover { background: #dc2626; }

.auth-links { text-align: center; margin-top: 1.5rem; font-size: 0.875rem; }
.auth-links a { color: var(--brand-accent); text-decoration: none; transition: color 0.2s; }
.auth-links a:hover { color: var(--brand-accent-hover); text-decoration: underline; }

/* Dashboard UI */
.staff-navbar { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: clamp(1rem, 3vw, 1.5rem) clamp(1rem, 5vw, 2.5rem); 
    background: var(--panel-glass); 
    border-bottom: 1px solid rgba(255,255,255,0.05); 
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-wrap: wrap; /* Flujo elástico para pantallas muy pequeñas */
    gap: 1rem;
}

.staff-navbar .brand { font-size: clamp(1.1rem, 3vw, 1.25rem); font-weight: 700; display: flex; align-items: center; }
.staff-navbar .badge { background: var(--brand-accent); font-size: 0.7rem; padding: 0.25rem 0.5rem; border-radius: 4px; color: white; margin-left: 0.5rem; letter-spacing: 0.5px; }

.user-controls { display: flex; align-items: center; gap: clamp(0.5rem, 2vw, 1.5rem); flex-wrap: wrap; }
#activeUserLabel { font-size: clamp(0.8rem, 2.5vw, 0.95rem); color: #cbd5e1; }

.dashboard-core { 
    padding: clamp(1.5rem, 5vw, 3rem); 
    flex-grow: 1;
    width: 100%;
    max-width: 1440px; /* Limite ultra-wide */
    margin: 0 auto;
}

.dashboard-core header h2 { font-size: var(--font-h1); margin-bottom: 0.5rem; }
.dashboard-core header p { font-size: clamp(0.9rem, 2vw, 1rem); }

/* Grid Responsive Avanzado (No-Media-Query Math Technique) */
.grid-8-modules { 
    display: grid; 
    /* El algoritmo min() asegura que la tarjeta se encoja al 100% del padre si es menor a 260px, resolviendo overflows en < 320px */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); 
    gap: clamp(1rem, 3vw, 2rem); 
}

.module-card { 
    background: #1e293b; 
    padding: clamp(1.5rem, 4vw, 2.5rem); 
    border-radius: 12px; 
    text-align: center; 
    cursor: pointer; 
    border: 1px solid rgba(255,255,255,0.05); 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.module-card:hover { 
    transform: translateY(-5px); 
    border-color: var(--brand-accent); 
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4); 
    background: #1e293b;
}
.module-card i { font-size: clamp(2rem, 5vw, 2.8rem); display: block; margin-bottom: 1rem; font-style: normal; }
.module-card h3 { font-size: clamp(1rem, 2.5vw, 1.15rem); font-weight: 600; color: #f1f5f9; }

/* Degradación elegante para resoluciones hostiles (Smartphones legacy en portrait) */
@media (max-width: 480px) {
    .staff-navbar {
        flex-direction: column;
        justify-content: center;
        text-align: center;
        padding-top: 1.25rem;
        padding-bottom: 1.25rem;
    }
    .user-controls {
        width: 100%;
        justify-content: center;
        flex-direction: column;
        margin-top: 0.5rem;
    }
    .btn-danger {
        width: 100%;
        margin-top: 0.5rem;
        padding: 0.875rem;
    }
    .dashboard-core {
        padding-top: 1.5rem;
    }
}

/* =======================================================
   UTILITIES PARA LOGIN/REGISTRO (Sobreescribiendo LogIn raíz)
   ======================================================= */

.staff-form-wide {
    max-width: 500px !important;
    padding: 25px !important;
}

.staff-auth-title {
    text-align: center;
    font-family: 'Montserrat', sans-serif;
    margin-bottom: 24px;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    /* Estilo ameno y orgánico (Acorde a Agricultura/Cordami) */
    background: linear-gradient(135deg, #15803d 0%, #22c55e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 4px 15px rgba(34, 197, 94, 0.2);
}

.staff-return-wrapper {
    margin-top: 15px;
    text-align: center;
}

.staff-return-link {
    color: #28a745 !important;
    text-decoration: none !important;
    font-weight: 500;
    transition: color 0.2s;
}

.staff-return-link:hover {
    color: #218838 !important;
    text-decoration: underline !important;
}

/* =========================================================
   STAFF UI OVERRIDES (Zero-Green / Corporate Blue Mode)
   ========================================================= */

/* 1. Cambio de borde verde a borde izquierdo azul */
.dashboard-grid .dash-card {
    border-top: none !important;
    border-left: 4px solid #2a5298 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255,255,255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.dashboard-grid .dash-card:hover {
    border-left: 6px solid #1e3c72 !important;
    box-shadow: 0 10px 25px rgba(42, 82, 152, 0.12) !important;
    transform: translateY(-4px);
    background: #ffffff;
    cursor: pointer;
}

.dashboard-grid .dash-card:hover h3 {
    color: #1e3c72 !important;
}

/* 2. Resaltado jerárquico del Usuario (Profile Badge) */
.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(42, 82, 152, 0.06);
    padding: 6px 18px 6px 6px;
    border-radius: 50px;
    border: 1px solid rgba(42, 82, 152, 0.15);
    transition: background 0.3s;
    white-space: nowrap;
}
.user-profile-badge:hover {
    background: rgba(42, 82, 152, 0.1);
}
.user-avatar-circle {
    width: 32px;
    height: 32px;
    background: #2a5298;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
}
#activeUserLabel {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    white-space: nowrap;
}

/* =========================================================
   STAFF INTERNAL MODULES (Agenda, Forms, Layouts)
   ========================================================= */
   
.module-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 55px;
    height: 55px;
    background: rgba(42, 82, 152, 0.1);
    color: #1e3c72;
    border-radius: 50%;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 1px solid rgba(42, 82, 152, 0.2);
    cursor: pointer;
}
.btn-back svg {
    width: 28px;
    height: 28px;
}
.btn-back:hover {
    background: #1e3c72;
    color: #fff;
    transform: translateX(-3px);
}

.staff-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px 25px;
}

.staff-form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

.staff-form-group.full-width {
    grid-column: 1 / -1;
}

.staff-form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
}

.staff-form-group input,
.staff-form-group select,
.staff-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #1e293b;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.staff-form-group input:focus,
.staff-form-group select:focus,
.staff-form-group textarea:focus {
    border-color: #2a5298;
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.15);
}

.staff-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.staff-action-bar {
    display: flex;
    justify-content: flex-end;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(0,0,0,0.05);
}

/* Glass form container overrides */
.glass-panel.light-glass {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.05);
}

/* =========================================================
   AGENDA LIST ITEMS & STATUS UI
   ========================================================= */

.agenda-item {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(42, 82, 152, 0.1);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
}

.agenda-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.06);
}

.agenda-item.done {
    border-left: 6px solid #10b981;
    opacity: 0.85;
}

.agenda-item.pending {
    border-left: 6px solid #f59e0b;
}

.agenda-item-content {
    flex-grow: 1;
}

.agenda-item-title {
    color: #1e3c72;
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.agenda-item-meta {
    font-size: 0.85rem;
    color: #64748b;
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.agenda-item-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.agenda-item-actions {
    margin-left: 20px;
}

.btn-toggle-status {
    padding: 8px 18px;
    border-radius: 50px;
    border: none;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.btn-status-pending {
    background: #fef3c7;
    color: #d97706;
}
.btn-status-pending:hover {
    background: #fde68a;
}

.btn-status-done {
    background: #d1fae5;
    color: #059669;
}
.btn-status-done:hover {
    background: #a7f3d0;
}

@media (max-width: 768px) {
    .staff-form-grid {
        grid-template-columns: 1fr;
    }
    .agenda-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .agenda-item-actions {
        margin-left: 0;
        width: 100%;
    }
    .btn-toggle-status {
        width: 100%;
    }
}
