/* ==================== VARIABLES ==================== */
:root {
    --primary: #1e40af;
    --primary-hover: #1e3a8a;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #10b981;
    --success-bg: #d1fae5;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --info: #3b82f6;

    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);

    --navbar-h: 62px;
    --transition: all 0.2s ease;
}

/* ==================== RESET ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ==================== NAVBAR ==================== */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--navbar-h);
    background: var(--primary);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.navbar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    letter-spacing: .3px;
    flex: 1;
}

.navbar-brand span {
    display: block;
    font-size: .7rem;
    font-weight: 400;
    opacity: .75;
    letter-spacing: 0;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #fff;
    font-size: .85rem;
}

.badge-role {
    padding: .2rem .55rem;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.badge-role.admin    { background: #fbbf24; color: #78350f; }
.badge-role.supervisor { background: #34d399; color: #065f46; }
.badge-role.operador { background: rgba(255,255,255,.25); color: #fff; }

.btn-logout {
    padding: .35rem .85rem;
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: var(--radius-sm);
    font-size: .82rem;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}
.btn-logout:hover { background: rgba(255,255,255,.25); }

/* ==================== PAGE WRAPPER ==================== */
.page {
    padding-top: calc(var(--navbar-h) + 1.5rem);
    padding-bottom: 2rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
    max-width: 1100px;
    margin: 0 auto;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1.5rem;
}

/* ==================== CARDS ==================== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    border: 1px solid var(--border);
}

/* ==================== MENU GRID ==================== */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: .5rem;
}

.menu-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1.25rem;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .6rem;
}
.menu-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
    color: var(--primary);
}
.menu-card .menu-icon {
    font-size: 2rem;
    line-height: 1;
}
.menu-card .menu-label {
    font-size: .9rem;
    font-weight: 600;
}

/* ==================== LOGIN ==================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
    padding: 1rem;
}

.login-box {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
}

.login-logo {
    text-align: center;
    margin-bottom: 1.75rem;
}
.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -.5px;
}
.login-logo p {
    font-size: .82rem;
    color: var(--text-muted);
    margin-top: .2rem;
}

.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: .3rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.form-group input,
.form-group select {
    width: 100%;
    padding: .65rem .85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .95rem;
    color: var(--text);
    background: #fff;
    transition: var(--transition);
    outline: none;
}
.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,64,175,.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .65rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-full { width: 100%; }

.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    margin-bottom: 1rem;
}
.alert-error { background: var(--danger-bg); color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #6ee7b7; }

/* ==================== TABLE ==================== */
.table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
table.data-table th {
    background: var(--bg);
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: .75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
}
table.data-table td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: var(--bg); }

.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-admin    { background: #fef3c7; color: #92400e; }
.badge-supervisor { background: var(--success-bg); color: #065f46; }
.badge-operador { background: var(--primary-light); color: #1e40af; }

/* ==================== MODAL ==================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 460px;
    padding: 1.75rem;
    animation: slideUp .2s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: .1rem .3rem;
}
.modal-close:hover { color: var(--text); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
    margin-top: 1.25rem;
}

/* ==================== TOAST ==================== */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.toast {
    padding: .75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: slideIn .2s ease;
    min-width: 220px;
}
@keyframes slideIn {
    from { transform: translateX(40px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}
.toast-success { background: var(--success); color: #fff; }
.toast-error   { background: var(--danger);  color: #fff; }
.toast-info    { background: var(--info);    color: #fff; }

/* ==================== SECTION HEADER ==================== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: .75rem;
}
.section-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

/* ==================== BACK LINK ==================== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    color: var(--primary);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
}
.back-link:hover { text-decoration: underline; }

/* ==================== BUSQUEDA (mantiene compatibilidad) ==================== */
#searchForm { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
#keywordInput { flex: 1; min-width: 150px; padding: .55rem .85rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .95rem; outline: none; }
#keywordInput:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,64,175,.1); }

.hidden { display: none !important; }

#loader { display: flex; justify-content: center; align-items: center; padding: 2rem; }
#loader img { width: 48px; height: 48px; }

#resultados { width: 100%; border-collapse: collapse; }
#resultados th, #resultados td { border: 1px solid var(--border); padding: .65rem .85rem; text-align: left; font-size: .88rem; }
#resultados th { background: var(--bg); color: var(--text-muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 600px) {
    .navbar-brand span { display: none; }
    .navbar-user .user-name { display: none; }
    .menu-grid { grid-template-columns: repeat(2, 1fr); }
    .page { padding-left: .85rem; padding-right: .85rem; }
    .login-box { padding: 2rem 1.25rem; }
}
