/* ============================================================================
   Instituto Politecnico de la Frontera — Area de Sistemas
   Estilos del Sistema de Inventario y Control de Accesos
   Paleta institucional: Turquesa, Dorado, Azul (basada en escudo IPF)
   ============================================================================ */

:root {
    /* ── Colores institucionales (del escudo IPF) ───────────────── */
    --primary: #1A7D7A;           /* Turquesa profundo (ovalo del escudo) */
    --primary-light: #228F8B;     /* Turquesa medio (hover) */
    --primary-dark: #145F5D;      /* Turquesa oscuro */
    --secondary: #CDA03C;         /* Dorado institucional (montanas) */
    --secondary-light: #DFB85E;   /* Dorado claro (hover) */
    --accent: #E5F4F3;            /* Turquesa muy claro (fondos) */
    --accent-gold: #FFF8E7;       /* Dorado muy claro (fondos) */
    --river-blue: #3578BE;        /* Azul (rio del escudo) */

    /* ── Layout ─────────────────────────────────────────────────── */
    --sidebar-width: 260px;
    --navbar-height: 60px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Base ─────────────────────────────────────────────────────────── */

body {
    font-family: var(--font-family);
    background-color: #f4f6f9;
    color: #333;
    overflow-x: hidden;
}

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ── Sidebar ─────────────────────────────────────────────────────── */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

.sidebar-header {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary) 0%, #228F8B 100%);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}
.sidebar-brand:hover { text-decoration: none; }

.sidebar-brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: contain;
    flex-shrink: 0;
    background: #fff;
    padding: 2px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Fallback si no carga la imagen */
.sidebar-brand-icon {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.3);
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.sidebar-brand-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
}

.sidebar-brand-subtitle {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.75);
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 0.6rem 0;
}

.sidebar-section-label {
    padding: 0.7rem 1.2rem 0.3rem;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem 1.2rem;
    margin: 1px 0.6rem;
    border-radius: 8px;
    color: #475569;
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    transition: all 0.15s ease;
}
.sidebar-link i {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.sidebar-link:hover {
    background: var(--accent);
    color: var(--primary);
    text-decoration: none;
}
.sidebar-link.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(26,125,122,0.3);
}
.sidebar-link.active i { color: #fff; }

.sidebar-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 0.5rem 1.2rem;
}

.sidebar-link-logout { color: #dc3545; }
.sidebar-link-logout:hover { background: #fef2f2; color: #b91c1c; }

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 1035;
}
.sidebar-overlay.show { display: block; }

/* ── Top Navbar ──────────────────────────────────────────────────── */

.topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--navbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1030;
    transition: left 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-toggle {
    display: none;
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.35rem 0.55rem;
    cursor: pointer;
    color: #475569;
    font-size: 1.05rem;
}
.topbar-toggle:hover {
    background: var(--accent);
    color: var(--primary);
}

.topbar-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
}

.topbar-user-role {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 50px;
}
.role-admin { background: var(--accent); color: var(--primary); }
.role-viewer { background: #f1f5f9; color: #64748b; }

.topbar-btn-logout {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: none;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.15s ease;
}
.topbar-btn-logout:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc3545;
}

/* ── Main Content ────────────────────────────────────────────────── */

.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--navbar-height);
    min-height: calc(100vh - var(--navbar-height));
    transition: margin-left 0.3s ease;
}

/* ── Dashboard Cards ─────────────────────────────────────────────── */

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.3rem;
    border-left: 4px solid var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
}
.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}
.stat-card .stat-label {
    font-size: 0.78rem;
    color: #64748b;
    font-weight: 500;
}

.stat-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}
.stat-card-link:hover { color: inherit; text-decoration: none; }

/* ── Tables ──────────────────────────────────────────────────────── */

.card-table {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
}

.card-table .card-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-table .card-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
}

.card-table .card-body {
    padding: 1rem;
}

table.dataTable thead th {
    background: var(--primary) !important;
    color: #fff !important;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.65rem 0.75rem !important;
    border-bottom: none !important;
    white-space: nowrap;
}

table.dataTable tbody td {
    font-size: 0.82rem;
    padding: 0.55rem 0.75rem !important;
    vertical-align: middle;
}

table.dataTable tbody tr:hover {
    background-color: var(--accent) !important;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    font-size: 0.82rem;
}

/* DataTables pagination active state */
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}

/* ── Password Field ──────────────────────────────────────────────── */

.password-cell {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.password-dots {
    font-family: monospace;
    letter-spacing: 2px;
    color: #94a3b8;
}

.btn-reveal-password {
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.15rem 0.4rem;
    cursor: pointer;
    color: #64748b;
    font-size: 0.75rem;
    transition: all 0.15s;
}
.btn-reveal-password:hover {
    background: var(--accent);
    color: var(--primary);
    border-color: var(--primary);
}

/* ── Status Badges ───────────────────────────────────────────────── */

.badge-status {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: 50px;
    letter-spacing: 0.02em;
}
.badge-activo { background: #dcfce7; color: #166534; }
.badge-inactivo { background: #f1f5f9; color: #475569; }
.badge-mantenimiento { background: #fef3c7; color: #92400e; }
.badge-baja { background: #fce4ec; color: #b71c1c; }

/* ── Forms ────────────────────────────────────────────────────────── */

.form-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.form-card .card-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.25rem;
}
.form-card .card-header h5 {
    margin: 0;
    font-weight: 600;
    color: var(--primary);
}
.form-card .card-body {
    padding: 1.5rem;
}

.form-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    padding-bottom: 0.4rem;
    margin-bottom: 1rem;
    margin-top: 1.5rem;
    border-bottom: 2px solid var(--accent);
}
.form-section-title:first-child { margin-top: 0; }

.form-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: #475569;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(26,125,122,0.15);
}

/* ── Login Page ──────────────────────────────────────────────────── */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 40%, #228F8B 70%, var(--river-blue) 100%);
    padding: 1rem;
    position: relative;
}

/* Patron decorativo sutil */
.login-page::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at 30% 80%, rgba(205,160,60,0.1) 0%, transparent 50%),
                radial-gradient(circle at 70% 20%, rgba(255,255,255,0.05) 0%, transparent 40%);
    pointer-events: none;
}

.login-container {
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem 2rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo-img {
    width: 90px;
    height: 90px;
    margin: 0 auto 1rem;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}

/* Fallback si no carga el logo */
.login-logo {
    width: 70px;
    height: 70px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.8rem;
}

.login-header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.3rem;
}

.login-header p {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0;
}

.login-header .login-subtitle-area {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.25rem;
    padding: 0.2rem 0.7rem;
    background: var(--accent-gold);
    border-radius: 50px;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
    color: #94a3b8;
    font-size: 0.72rem;
}

/* Login form button con dorado */
.login-card .btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    font-weight: 600;
    letter-spacing: 0.01em;
}
.login-card .btn-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
}

/* ── Action Buttons ──────────────────────────────────────────────── */

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-light);
    border-color: var(--primary-light);
}
.btn-primary:active {
    background: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Boton dorado para acciones especiales */
.btn-gold {
    background: var(--secondary);
    border-color: var(--secondary);
    color: #fff;
}
.btn-gold:hover {
    background: var(--secondary-light);
    border-color: var(--secondary-light);
    color: #fff;
}

.btn-action {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 6px;
}

.actions-cell {
    white-space: nowrap;
}

/* ── Alerts ──────────────────────────────────────────────────────── */

.alert {
    border-radius: 10px;
    font-size: 0.85rem;
    border: none;
}

/* ── Activity List (Dashboard) ───────────────────────────────────── */

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid #f1f5f9;
}
.activity-item:last-child { border-bottom: none; }

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.activity-text {
    font-size: 0.8rem;
    color: #475569;
    line-height: 1.4;
}
.activity-text strong { color: #334155; }
.activity-time {
    font-size: 0.7rem;
    color: #94a3b8;
}

/* ── Sidebar Footer / Version ────────────────────────────────────── */

.sidebar-footer {
    padding: 0.6rem 1.2rem;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.sidebar-footer-text {
    font-size: 0.62rem;
    color: #94a3b8;
    text-align: center;
    line-height: 1.4;
}

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    .sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 16px rgba(0,0,0,0.1);
    }
    .topbar { left: 0; }
    .topbar-toggle { display: inline-flex; }
    .main-content { margin-left: 0; }
    .topbar-user-name { display: none; }
}

@media (max-width: 575.98px) {
    .topbar-title { font-size: 0.9rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .stat-card .stat-value { font-size: 1.4rem; }
    .login-card { padding: 2rem 1.5rem; }
    .login-logo-img { width: 75px; height: 75px; }
}

/* ── Print ────────────────────────────────────────────────────────── */

@media print {
    .sidebar, .topbar, .sidebar-overlay, .topbar-toggle,
    .btn, .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_paginate { display: none !important; }
    .main-content { margin: 0 !important; }
    body { background: #fff; }
}
