/* =========================================================
   MAIN.CSS MAESTRO DEFINITIVO
   Sistema único de tema: light / dark / contrast
   ========================================================= */

/* =========================================================
   TOKENS GLOBALES
   ========================================================= */
:root,
[data-theme="light"] {

    /* Fondos */
    --bg-body: #F1F5F9; /* color navbar  #eef3f8 */
    --bg-card: #ffffff;
    --bg-sidebar: #F1F5F9;
    --bg-sidebar-soft: #F1F5F9;
    --bg-navbar: #F1F5F9; /* color navbar #f7f9fc #DFEFF4 #F4F5F7*/
    --bg-input: #f8fafc;
    --bg-hover: #edf4ff;
    --bg-active: rgba(0, 71, 171, 0.08);

    /* Texto */
    --text-main: #151515;
    --text-muted: #303030;
    --text-soft: #2b2828;
    --text-inverse: #ffffff;

    /* Bordes */
    --border-color: #d8e2ef;
    --border-strong: #c4d0df;

    /* Identidad NoaConecta */
    --primary: #0D4C99;
    --primary-dark: #003580;
    --primary-light: rgba(0, 71, 171, 0.10);
    --primary-soft: rgba(0, 71, 171, 0.12);
    --primary-text: #151515 !important;

    /* Secundarios */
    --secondary: #475569;
    --secondary-light: rgba(71, 85, 105, 0.10);

    --success: #16a34a;
    --success-light: rgba(22, 163, 74, 0.10);

    --danger: #dc2626;
    --danger-light: rgba(220, 38, 38, 0.10);

    --warning: #d97706;
    --warning-light: rgba(217, 119, 6, 0.10);

    --info: #0891b2;
    --info-light: rgba(8, 145, 178, 0.10);

    /* Sidebar */
    --sidebar-border: #d8e2ef;
    --sidebar-text: #334155;
    --sidebar-text-muted: #64748b;
    --sidebar-heading: #0f172a;

    --sidebar-hover: rgba(0, 71, 171, 0.06);
    --sidebar-active: rgba(0, 71, 171, 0.12);
    --sidebar-active-text: #0D4C99;

    /* Sombras */
    --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
    --shadow-sm: 0 2px 8px rgba(15,23,42,.06);
    --shadow-md: 0 8px 24px rgba(15,23,42,.08);
    --shadow-lg: 0 18px 40px rgba(15,23,42,.12);

    /* Radios */
    --radius-xs: 8px;
    --radius-sm: 10px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 999px;

    /* Layout */
    --sidebar-width: 260px;
    --navbar-height: 64px;
    --content-padding: 24px;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --transition-fast: 0.16s ease;
    --transition-base: 0.24s ease;
}

/* =========================================================
   TEMA OSCURO (Dark Mode)
   ========================================================= */
body.dark-mode,
[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: #111c31;
    --bg-sidebar: #0b1324;
    --bg-sidebar-soft: #101b31;
    --bg-navbar: rgba(15, 23, 42, 0.82);
    --bg-input: #162338;
    --bg-hover: #1b2a44;
    --bg-active: #123832;
    --text-main: #e8eef8;
    --text-muted: #9fb0c7;
    --text-soft: #70839d;
    --text-inverse: #08111f;
    --border-color: #22314a;
    --border-strong: #30415e;
    /* COLORES PRIMARIOS SIEMPRE AZULES - NUNCA VERDES */
    --primary: #0D4C99 !important;
    --primary-dark: #003580 !important;
    --primary-light: rgba(0, 71, 171, 0.18);
    --primary-soft: rgba(0, 71, 171, 0.16);
    --secondary: #9fb0c7;
    --secondary-light: rgba(159, 176, 199, 0.14);
    --success: #16a34a !important;
    --success-light: rgba(22, 163, 74, 0.16) !important;
    --danger: #dc2626 !important;
    --danger-light: rgba(220, 38, 38, 0.16) !important;
    --warning: #d97706 !important;
    --warning-light: rgba(217, 119, 6, 0.16) !important;
    --info: #0891b2 !important;
    --info-light: rgba(8, 145, 178, 0.16) !important;
    --sidebar-border: #1e2b40;
    --sidebar-text: #dbe7f5;
    --sidebar-text-muted: #93a4ba;
    --sidebar-heading: #ffffff;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(0, 71, 171, 0.18);
    --sidebar-active-text: #0D4C99 !important;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.34);
    --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.46);
}

/* =========================================================
   TEMA ALTO CONTRASTE
   ========================================================= */
body.high-contrast,
[data-theme="contrast"] {
    --bg-body: #000000;
    --bg-card: #000000;
    --bg-sidebar: #000000;
    --bg-sidebar-soft: #000000;
    --bg-navbar: rgba(0, 0, 0, 0.98);
    --bg-input: #000000;
    --bg-hover: #111111;
    --bg-active: #111111;
    --text-main: #ffffff;
    --text-muted: #f5f5f5;
    --text-soft: #d4d4d4;
    --text-inverse: #000000;
    --border-color: #ffffff;
    --border-strong: #ffffff;
    --primary: #00ffff;
    --primary-dark: #00e0e0;
    --primary-light: rgba(0, 255, 255, 0.18);
    --primary-soft: rgba(0, 255, 255, 0.18);
    --secondary: #ffffff;
    --secondary-light: rgba(255, 255, 255, 0.18);
    --success: #00ff66;
    --success-light: rgba(0, 255, 102, 0.18);
    --danger: #ff4d4d;
    --danger-light: rgba(255, 77, 77, 0.18);
    --warning: #ffcc00;
    --warning-light: rgba(255, 204, 0, 0.18);
    --info: #00ffff;
    --info-light: rgba(0, 255, 255, 0.18);
    --sidebar-border: #ffffff;
    --sidebar-text: #ffffff;
    --sidebar-text-muted: #ffffff;
    --sidebar-heading: #ffffff;
    --sidebar-hover: #111111;
    --sidebar-active: #00ffff;
    --sidebar-active-text: #000000;
    --shadow-xs: none;
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
}

/* =========================================================
   RESET / BASE
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; max-width: 100%; overflow-x: hidden; }
body {
    margin: 0; padding: 0;
    font-family: var(--font-family);
    font-size: 14px; line-height: 1.5;
    color: var(--text-main);
    background: var(--bg-body);
    max-width: 100%; overflow-x: hidden;
    transition: background-color var(--transition-base), color var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
}
img, svg, video, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
::placeholder { color: var(--text-soft); opacity: 1; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.text-muted { color: var(--text-muted) !important; }
.text-main { color: var(--text-main) !important; }
.bg-body { background: var(--bg-body) !important; }
.bg-card { background: var(--bg-card) !important; }

/* =========================================================
   AUTH / LOGIN
   ========================================================= */
.bg-auth {
    min-height: 100vh;

    background:
        radial-gradient(
            circle at top left,
            rgba(0,71,171,.20),
            transparent 40%
        ),
        radial-gradient(
            circle at bottom right,
            rgba(47,73,255,.15),
            transparent 40%
        ),
        #0b1424;

    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0px;
}
.auth-wrapper { width: 100%; max-width: 540px; }
.auth-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); overflow: hidden; }


.auth-header { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: #fff; text-align: center; padding: 36px 28px; }


.auth-logo { width: 72px; height: 75px; margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; font-size: 30px; }
.auth-title { margin: 0 0 6px; font-size: 24px; font-weight: 700; }
.auth-subtitle { margin: 0; font-size: 14px; opacity: 0.92; }
.auth-body { padding: 28px; }
.auth-footer { padding: 16px 28px; background: var(--bg-input); border-top: 1px solid var(--border-color); text-align: center; color: var(--text-muted); }

/* =========================================================
   APP LAYOUT
   ========================================================= */
.app-body { background: var(--bg-body); }
.app-container { display: flex; min-height: 100vh; overflow-x: hidden; }
.app-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--bg-sidebar) 0%, var(--bg-sidebar-soft) 100%);
    color: var(--sidebar-text); border-right: 1px solid var(--sidebar-border);
    display: flex; flex-direction: column; z-index: 1040;
    overflow-x: hidden; overflow-y: auto;
    transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}
.app-main { flex: 1; min-width: 0; margin-left: var(--sidebar-width); display: flex; flex-direction: column; overflow-x: hidden; }
.app-content { flex: 1; padding: var(--content-padding); margin-top: var(--navbar-height); overflow-x: hidden; }

/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar-header { height: var(--navbar-height); display: flex; align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--sidebar-border); }
.sidebar-logo { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: var(--shadow-sm); font-size: 20px; flex-shrink: 0; overflow: hidden; }
.sidebar-logo img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.sidebar-title strong { display: block; font-size: 14px; color: var(--sidebar-heading); line-height: 1.2; }
.sidebar-title small { color: var(--sidebar-text-muted); font-size: 11px; }
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px 10px 14px 12px; scrollbar-width: thin; scrollbar-color: rgba(100, 116, 139, 0.32) transparent; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, 0.28); border-radius: 999px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, 0.45); }
.nav-item { margin-bottom: 4px; }
.nav-link { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 100%; padding: 11px 12px; border-radius: 10px; color: var(--sidebar-text); transition: all var(--transition-fast); font-size: 13px; font-weight: 500; }
.nav-link i { width: 20px; text-align: center; font-size: 17px; flex-shrink: 0; }
.nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-heading); }
.nav-item.active > .nav-link, .nav-link.active { background: var(--sidebar-active); color: var(--sidebar-active-text); font-weight: 600; }
.submenu-toggle { width: 100%; border: 0; background: transparent; text-align: left; justify-content: space-between; }
.submenu-toggle .bi-chevron-down { transition: transform var(--transition-fast); transform-origin: center; flex-shrink: 0; }
.rotate-180 { transform: rotate(180deg); }
.submenu { max-height: 0; overflow: hidden; overflow-x: hidden; transition: max-height 0.24s ease; padding-left: 16px; }
.submenu.open { max-height: 500px; }
.submenu-link { display: block; width: 100%; max-width: 100%; padding: 8px 10px; margin: 4px 0; border-radius: 8px; color: var(--sidebar-text-muted); font-size: 13px; transition: all var(--transition-fast); }
.submenu-link:hover { background: var(--sidebar-hover); color: var(--sidebar-heading); }
.submenu-link.active { background: var(--sidebar-active); color: var(--sidebar-active-text); font-weight: 600; }
.sidebar-footer { padding: 14px 20px; border-top: 1px solid var(--sidebar-border); color: var(--sidebar-text-muted); font-size: 11px; }

/* =========================================================
   NAVBAR
   ========================================================= */
.app-navbar { position: fixed; top: 0; right: 0; left: var(--sidebar-width); height: var(--navbar-height); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: var(--bg-navbar); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--border-color); z-index: 1030; }
.navbar-left, .navbar-right { display: flex; align-items: center; gap: 14px; }
.btn-user { display: flex; align-items: center; gap: 12px; border: 0; background: transparent; border-radius: 12px; padding: 6px 10px 6px 6px; color: var(--text-main); transition: background var(--transition-fast); }
.btn-user:hover { background: var(--bg-hover); }
.user-avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-main); line-height: 1.2; }
.user-role { font-size: 11px; color: var(--text-muted); }
.btn-theme-toggle, .btn-sidebar-toggle { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); display: inline-flex; align-items: center; justify-content: center; transition: all var(--transition-fast); }
.btn-theme-toggle:hover, .btn-sidebar-toggle:hover { background: var(--bg-hover); }

/* =========================================================
   FOOTER
   ========================================================= */
.app-footer { padding: 16px 24px; border-top: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-muted); display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; }

/* =========================================================
   TARJETAS / PANEL
   ========================================================= */
.card, .panel { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.card-header, .panel-header { background: var(--bg-card); border-bottom: 1px solid var(--border-color); padding: 16px 20px; color: var(--text-main); }
.card-body, .panel-body { padding: 20px; }
.card-footer, .panel-footer { padding: 14px 20px; background: var(--bg-input); border-top: 1px solid var(--border-color); color: var(--text-muted); }
.panel-title, .card-header h5, .card-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--text-main); }
.panel-title i, .card-header h5 i { color: var(--primary); }

/* =========================================================
   STATS
   ========================================================= */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 24px; }
.stat-card { display: flex; align-items: center; gap: 16px; padding: 20px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); transition: transform var(--transition-fast), box-shadow var(--transition-fast); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 24px; }
.stat-icon.blue { background: var(--info-light); color: var(--info); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.purple { background: rgba(124, 58, 237, 0.14); color: #7c3aed; }
.stat-icon.cyan { background: rgba(8, 145, 178, 0.14); color: #0891b2; }
.stat-info h3 { margin: 0; font-size: 28px; line-height: 1; color: var(--text-main); font-weight: 800; }
.stat-info p { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }

/* =========================================================
   TOOLBAR
   ========================================================= */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.search-box { position: relative; flex: 1; min-width: 250px; }
.search-box i { position: absolute; top: 50%; left: 14px; transform: translateY(-50%); color: var(--text-soft); }
.search-box input { width: 100%; padding: 10px 14px 10px 40px; }

/* =========================================================
   FORMULARIOS
   ========================================================= */
.form-label, .form-group label { display: block; margin-bottom: 6px; color: var(--text-muted); font-size: 13px; font-weight: 600; }
.form-control, .form-select, .form-control-custom, textarea.form-control, select.form-select {
    width: 100%; min-height: 42px; padding: 10px 14px;
    background: var(--bg-input); color: var(--text-main);
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}
.form-control:focus, .form-select:focus, .form-control-custom:focus {
    outline: none; border-color: var(--primary);
    background: var(--bg-card); box-shadow: 0 0 0 4px var(--primary-soft);
}
.input-group-text { background: var(--bg-input); color: var(--text-muted); border: 1px solid var(--border-color); }
.form-text, small, small.text-muted { color: var(--text-muted) !important; }
.form-control.is-invalid, .form-select.is-invalid, .form-control-custom.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-light); }
.invalid-feedback, .invalid-feedback-custom { display: block; margin-top: 4px; color: var(--danger); font-size: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-section { margin-bottom: 24px; }
.form-section-title { margin: 0 0 16px; padding-bottom: 8px; font-size: 15px; font-weight: 700; color: var(--text-main); border-bottom: 1px solid var(--border-color); }

/* =========================================================
   FILTROS / BUSCADOR UNIFICADOS
   ========================================================= */
.toolbar-filters, .filters-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-box input, .toolbar select, .filters-row select, .filters-row .form-select, .toolbar .form-select {
    min-height: 38px; height: 38px; padding: 0 12px;
    border: 1px solid var(--border-color); border-radius: 10px;
    background: var(--bg-card); color: var(--text-main);
    font-size: 13px; line-height: 1; box-shadow: none;
}
.search-box input { padding-left: 40px; }
.toolbar select, .filters-row select, .filters-row .form-select, .toolbar .form-select {
    min-width: 118px;
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 16px) calc(50% - 3px), calc(100% - 10px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
    padding-right: 28px;
}
.search-box input:focus, .toolbar select:focus, .filters-row select:focus, .filters-row .form-select:focus, .toolbar .form-select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft);
}

/* =========================================================
   BOTONES
   ========================================================= */
.btn { border-radius: 10px; font-weight: 600; border: 1px solid transparent; transition: all var(--transition-fast); box-shadow: none !important; }
.btn:focus { box-shadow: 0 0 0 4px var(--primary-soft) !important; }
.btn-primary { background: #0D4C99 !important; border-color: #0D4C99 !important; color: #fff !important; }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active { background: #003580 !important; border-color: #003580 !important; color: #fff !important; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.94); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.94); color: #fff; }
.btn-info { background: var(--info); border-color: var(--info); color: #fff; }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-secondary { background: var(--secondary); border-color: var(--secondary); color: #fff; }
.btn-outline-primary, .btn-soft-primary { background: var(--primary-light); border-color: transparent; color: var(--primary); }
.btn-outline-primary:hover, .btn-soft-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-outline-danger, .btn-soft-danger { background: var(--danger-light); border-color: transparent; color: var(--danger); }
.btn-outline-danger:hover, .btn-soft-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-outline-secondary, .btn-soft-secondary { background: var(--secondary-light); border-color: transparent; color: var(--secondary); }
.btn-outline-secondary:hover, .btn-soft-secondary:hover { background: var(--secondary); border-color: var(--secondary); color: #fff; }
.btn-outline-info, .btn-soft-info { background: var(--info-light); border-color: transparent; color: var(--info); }
.btn-outline-info:hover, .btn-soft-info:hover { background: var(--info); border-color: var(--info); color: #fff; }
.btn-light { background: var(--bg-input); border-color: var(--border-color); color: var(--text-main); }
.btn-light:hover { background: var(--bg-hover); }

/* =========================================================
   BADGES
   ========================================================= */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1; }
.badge.bg-primary, .badge-soft-primary { background: var(--primary-light) !important; color: var(--primary) !important; }
.badge.bg-info, .badge-soft-info { background: var(--info-light) !important; color: var(--info) !important; }
.badge.bg-success, .badge-soft-success, .badge-estado.activo { background: var(--success-light) !important; color: var(--success) !important; }
.badge.bg-danger, .badge-soft-danger, .badge-estado.inactivo { background: var(--danger-light) !important; color: var(--danger) !important; }
.badge.bg-warning, .badge-soft-warning { background: var(--warning-light) !important; color: var(--warning) !important; }
.badge.bg-secondary, .badge-soft-secondary, .badge-estado.qr-no { background: var(--secondary-light) !important; color: var(--secondary) !important; }
.badge.bg-dark { background: var(--bg-input) !important; color: var(--text-main) !important; }
.badge-estado.qr-si { background: var(--info-light) !important; color: var(--info) !important; }

/* =========================================================
   TABLAS
   ========================================================= */
.table-responsive, .data-table-wrapper { overflow-x: auto; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-card); }
.table, .data-table { width: 100%; margin-bottom: 0; border-collapse: collapse; color: var(--text-main); background: transparent; }
.table > :not(caption) > * > *, .data-table th, .data-table td { padding: 12px 16px; vertical-align: middle; border-bottom: 1px solid var(--border-color); background: transparent; color: var(--text-main); }
.table thead, .data-table thead { background: var(--bg-input); }
.table thead th, .data-table thead th { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); border-bottom: 2px solid var(--border-color); background: var(--bg-input); white-space: nowrap; }
.table-light, .table-light th, .table-light td { background: var(--bg-input) !important; color: var(--text-main) !important; border-color: var(--border-color) !important; }
.table-hover > tbody > tr:hover > *, .data-table tbody tr:hover { background: var(--bg-hover) !important; }
.table tbody td strong, .data-table tbody td strong { color: var(--text-main); }
.table tbody td small, .data-table tbody td small { color: var(--text-muted); }

/* =========================================================
   CELDAS ESPECIALES
   ========================================================= */
.alumno-cell { display: flex; align-items: center; gap: 12px; }
.alumno-avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--info), #1d4ed8); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.alumno-avatar img { width: 100%; height: 100%; object-fit: cover; }
.alumno-name { max-width: 220px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text-main); font-weight: 600; }
.alumno-rut { font-family: monospace; font-size: 12px; color: var(--text-muted); }

/* =========================================================
   ACTION BUTTONS
   ========================================================= */
.action-btns { display: flex; gap: 6px; }
.btn-action { width: 34px; height: 34px; border: 0; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; transition: all var(--transition-fast); font-size: 16px; }
.btn-action.edit { background: var(--info-light); color: var(--info); }
.btn-action.edit:hover { background: var(--info); color: #fff; }
.btn-action.qr { background: var(--success-light); color: var(--success); }
.btn-action.qr:hover { background: var(--success); color: #fff; }
.btn-action.delete { background: var(--danger-light); color: var(--danger); }
.btn-action.delete:hover { background: var(--danger); color: #fff; }
.btn-action.view { background: var(--secondary-light); color: var(--secondary); }
.btn-action.view:hover { background: var(--secondary); color: #fff; }

/* =========================================================
   PAGINACIÓN
   ========================================================= */
.pagination-wrapper { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 0; }
.pagination-info { font-size: 13px; color: var(--text-muted); }
.pagination, .pagination ul { display: flex; align-items: center; gap: 4px; list-style: none; padding: 0; margin: 0; }
.page-link, .pagination li a, .pagination li span { min-width: 36px; height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); display: inline-flex; align-items: center; justify-content: center; transition: all var(--transition-fast); }
.page-link:hover, .pagination li a:hover { background: var(--bg-hover); border-color: var(--border-strong); color: var(--text-main); }
.page-item.active .page-link, .pagination li.active span { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-item.disabled .page-link, .pagination li.disabled span { opacity: 0.45; pointer-events: none; }

/* =========================================================
   ALERTAS
   ========================================================= */
.alert { border: 1px solid transparent; border-radius: var(--radius-md); box-shadow: none; }
.alert-primary { background: var(--primary-light); border-color: var(--primary-light); color: var(--primary); }
.alert-success { background: var(--success-light); border-color: var(--success-light); color: var(--success); }
.alert-danger { background: var(--danger-light); border-color: var(--danger-light); color: var(--danger); }
.alert-warning { background: var(--warning-light); border-color: var(--warning-light); color: var(--warning); }
.alert-info { background: var(--info-light); border-color: var(--info-light); color: var(--info); }

/* =========================================================
   DROPDOWN / MODAL / BOOTSTRAP OVERRIDES
   ========================================================= */
.dropdown-menu { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.dropdown-item { color: var(--text-main); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--bg-hover); color: var(--text-main); }
.dropdown-divider { border-top-color: var(--border-color); }
.modal-content { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border-color); color: var(--text-main); }
.modal-footer { border-top: 1px solid var(--border-color); }
.btn-close { filter: none; }
body.dark-mode .btn-close, [data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(180%); }

/* =========================================================
   EMPTY / LOADING
   ========================================================= */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state i { font-size: 64px; margin-bottom: 16px; opacity: 0.45; }
.empty-state h3 { margin: 0 0 8px; font-size: 20px; color: var(--text-main); }
.empty-state p { margin: 0 0 18px; font-size: 14px; }
.loading-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.72); border-radius: var(--radius-lg); opacity: 0; pointer-events: none; transition: opacity var(--transition-fast); }
.loading-overlay.active { opacity: 1; pointer-events: auto; }
body.dark-mode .loading-overlay, [data-theme="dark"] .loading-overlay { background: rgba(11,18,32,0.72); }

/* =========================================================
   REPORTES
   ========================================================= */
.reporte-header { text-align: center; margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 3px solid var(--text-main); }
.reporte-header h1 { margin: 0; color: var(--primary-text); font-size: 24px; font-weight: 800; }
.reporte-header h2 { margin: 5px 0; color: var(--text-muted); font-size: 18px; font-weight: 600; }
.reporte-header small { color: var(--text-muted); font-size: 13px; }
.reporte-info { background: var(--bg-input); padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; color: var(--text-main); font-size: 14px; border: 1px solid var(--border-color); }
.reporte-table { font-size: 13px; }
.reporte-table thead th { background: var(--bg-input) !important; color: var(--text-main) !important; font-size: 11px; padding: 10px 12px; }
.reporte-table tbody td { padding: 8px 12px; vertical-align: top; }
.reporte-table .table-separator, .reporte-table .table-separator td { background: var(--bg-input) !important; }
.reporte-table .table-separator td { color: var(--primary) !important; border-bottom: 2px solid var(--border-color); }

/* =========================================================
   FILTER BAR PREMIUM (tabs de retiros, etc.)
   ========================================================= */
.filter-bar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border-color);
}
.filter-bar .btn-fecha, [data-period-btn] {
    padding: 4px 12px; font-size: 0.8rem; border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-card); color: var(--text-main);
    cursor: pointer; transition: all 0.15s;
}
.filter-bar .btn-fecha.active, [data-period-btn].active,
.filter-bar .btn-fecha.btn-primary, [data-period-btn].btn-primary {
    background: var(--primary); color: #fff; border-color: var(--primary);
}

/* =========================================================
   PAGINACIÓN CUSTOM (retiros/alertas)
   ========================================================= */
.paginacion {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 20px; border-top: 1px solid var(--border-color);
    flex-wrap: wrap; gap: 8px;
}
.paginacion .info-pagina { font-size: 0.85rem; color: var(--text-muted); }
.paginacion .btns-pagina { display: flex; gap: 4px; }
.paginacion .btn-pag {
    padding: 4px 10px; border: 1px solid var(--border-color);
    background: var(--bg-card); border-radius: 6px; cursor: pointer;
    font-size: 0.85rem; color: var(--text-main);
}
.paginacion .btn-pag:hover:not(:disabled) { background: var(--bg-hover); }
.paginacion .btn-pag.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.paginacion .btn-pag:disabled { opacity: 0.4; cursor: not-allowed; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 991px) {
    .app-sidebar { transform: translateX(-100%); transition: transform var(--transition-base); }
    .app-sidebar.show { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .app-main { margin-left: 0; }
    .app-navbar { left: 0; }
}
@media (max-width: 768px) {
    :root, [data-theme="light"], body.dark-mode, [data-theme="dark"], body.high-contrast, [data-theme="contrast"] { --content-padding: 16px; }
    .stats-grid, .form-row { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-box { min-width: auto; }
    .app-footer { flex-direction: column; align-items: flex-start; }
    .table > :not(caption) > * > *, .data-table th, .data-table td { padding: 10px 12px; font-size: 13px; }
    .alumno-name { max-width: 120px; }
    .toolbar-filters, .filters-row { width: 100%; flex-direction: column; align-items: stretch; }
    .toolbar select, .filters-row select, .filters-row .form-select, .toolbar .form-select { width: 100%; }
}

/* =========================================================
   IMPRESIÓN
   ========================================================= */
@media print {
    @page { margin: 10mm; size: A4; }
    body { background: #fff !important; color: #000 !important; font-size: 12px !important; }
    .app-navbar, .app-sidebar, .sidebar, .navbar, .no-print, .btn, button, .action-btns, .toolbar, .app-footer, .modal, .modal-backdrop { display: none !important; }
    .app-main { margin-left: 0 !important; width: 100% !important; }
    .app-content { margin-top: 0 !important; padding: 0 !important; }
    .panel, .card, .stat-card, .data-table-wrapper, .table-responsive { background: #fff !important; border: 1px solid #ccc !important; box-shadow: none !important; page-break-inside: avoid; }
    .panel-header, .card-header, .panel-body, .card-body, .panel-footer, .card-footer, .reporte-info { background: #fff !important; color: #000 !important; }
    .table, .data-table, .reporte-table { color: #000 !important; }
    .table thead th, .data-table thead th, .reporte-table thead th { background: #e9ecef !important; color: #000 !important; border: 1px solid #ccc !important; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    .table tbody td, .data-table tbody td, .reporte-table tbody td { color: #000 !important; border: 1px solid #ddd !important; background: #fff !important; }
    .badge, .badge-estado { border: 1px solid #999 !important; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    a { color: #000 !important; text-decoration: none !important; }
    .text-muted, small, .user-role { color: #666 !important; }
}

/* =========================================================
   FIX MODO OSCURO — INPUTS Y PLACEHOLDERS
   ========================================================= */
body.dark-mode .form-control,
body.dark-mode .form-control-lg,
body.dark-mode .form-select,
body.dark-mode input[type="text"],
body.dark-mode input[type="email"],
body.dark-mode input[type="number"],
body.dark-mode input[type="date"],
body.dark-mode textarea,
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-control-lg,
[data-theme="dark"] .form-select,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] textarea {
    color: var(--text-main) !important;
    -webkit-text-fill-color: var(--text-main) !important;
    background: var(--bg-input) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-control-lg:focus,
body.dark-mode .form-select:focus,
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-control-lg:focus,
[data-theme="dark"] .form-select:focus {
    background: var(--bg-input) !important;
    border-color: var(--primary) !important;
    color: var(--text-main) !important;
    -webkit-text-fill-color: var(--text-main) !important;
}

/* PLACEHOLDERS MODO OSCURO */
body.dark-mode ::placeholder,
body.dark-mode ::-webkit-input-placeholder,
body.dark-mode ::-moz-placeholder,
[data-theme="dark"] ::placeholder,
[data-theme="dark"] ::-webkit-input-placeholder,
[data-theme="dark"] ::-moz-placeholder {
    color: #94a3b8 !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #94a3b8 !important;
}

body.dark-mode .btn-outline-secondary {
    border-color: var(--border-color) !important;
    color: var(--text-muted) !important;
}

/* HEADER PERSONA (ejecutar_retiro) */
.header-persona {
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    color: white; border-radius: 12px; padding: 20px; margin-bottom: 20px;
    display: flex; align-items: center; gap: 16px;
}
.header-persona.alerta { background: linear-gradient(135deg, #dc3545 0%, #b02a37 100%); }
.header-persona.warning { background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%); color: #212529; }
.header-persona .avatar { width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: bold; flex-shrink: 0; }
.header-persona h2 { margin: 0; font-size: 1.4rem; font-weight: 700; }
.header-persona .rut { font-size: 1rem; opacity: 0.9; }
.header-persona .badge-tipo { display: inline-block; padding: 4px 12px; border-radius: 20px; background: rgba(255,255,255,0.3); font-size: 0.8rem; font-weight: 700; margin-top: 4px; }

/* BTN ALUMNO (ejecutar_retiro) */
.btn-alumno {
    display: block; width: 100%; padding: 16px 20px; margin-bottom: 10px;
    background: var(--bg-card); border: 2px solid var(--border-color);
    border-radius: 10px; text-align: left; cursor: pointer;
    transition: all 0.2s; font-size: 1rem; color: var(--text-main);
}
.btn-alumno:hover:not(:disabled) { border-color: var(--primary); background: var(--bg-input); transform: translateY(-1px); }
.btn-alumno:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-alumno strong { font-size: 1.1rem; display: block; margin-bottom: 4px; color: var(--text-main); }
.btn-alumno small { color: var(--text-muted); }

/* CAJAS DE CONTACTO / AVISO */
.caja-contacto, .caja-aviso {
    background: var(--warning-light); border: 2px solid var(--warning);
    border-radius: 10px; padding: 16px; margin-bottom: 20px;
    color: var(--text-main);
}
.caja-aviso h4 { margin: 0 0 15px 0; font-weight: 700; color: var(--warning); }
.caja-aviso .info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-color); }
.caja-aviso .info-row:last-child { border-bottom: none; }
.caja-aviso .info-label { font-weight: 600; color: var(--text-muted); }
.caja-aviso .info-value { color: var(--text-main); font-weight: 600; }
.caja-contacto h5 { margin: 0 0 10px 0; font-weight: 700; }
.caja-contacto .telefono { font-size: 1.4rem; font-weight: 700; color: var(--primary); text-decoration: none; }

/* =========================================================
   ESPACIADO ENTRE SECCIONES (agregar al final de main.css)
   Da "aire" entre paneles, cards y secciones consecutivas
   ========================================================= */

/* Separación por defecto entre paneles/cards consecutivos */
.app-content .panel,
.app-content .card {
    margin-bottom: 24px;
}
.app-content .panel:last-child,
.app-content .card:last-child {
    margin-bottom: 0;
}

/* Grids de tarjetas y filas con separación inferior */
.app-content .stats-grid {
    margin-bottom: 24px;
}

/* Bloques sueltos comunes en las páginas */
.app-content .alert {
    margin-bottom: 24px;
}

/* Contenedores en grid (ficha-grid, dash-grid, form-row usados como layout)
   no deben perder el gap interno, pero sí separar del bloque siguiente */
.app-content .ficha-grid,
.app-content .dash-grid {
    margin-bottom: 24px;
}

/* Dentro de columnas de un grid, los paneles apilados también se separan */
.ficha-grid > div > .panel,
.dash-grid > div > .panel {
    margin-bottom: 16px;
}
.ficha-grid > div > .panel:last-child,
.dash-grid > div > .panel:last-child {
    margin-bottom: 0;
}

/* =========================================================
   ESPACIADO ENTRE SECCIONES (agregar al final de main.css)
   Da "aire" entre paneles, cards y secciones consecutivas
   ========================================================= */

/* Separación por defecto entre paneles/cards consecutivos */
.app-content .panel,
.app-content .card {
    margin-bottom: 24px;
}
.app-content .panel:last-child,
.app-content .card:last-child {
    margin-bottom: 0;
}

/* Grids de tarjetas y filas con separación inferior */
.app-content .stats-grid {
    margin-bottom: 24px;
}

/* Bloques sueltos comunes en las páginas */
.app-content .alert {
    margin-bottom: 24px;
}

/* Contenedores en grid (ficha-grid, dash-grid, form-row usados como layout)
   no deben perder el gap interno, pero sí separar del bloque siguiente */
.app-content .ficha-grid,
.app-content .dash-grid {
    margin-bottom: 24px;
}

/* Dentro de columnas de un grid, los paneles apilados también se separan */
.ficha-grid > div > .panel,
.dash-grid > div > .panel {
    margin-bottom: 16px;
}
.ficha-grid > div > .panel:last-child,
.dash-grid > div > .panel:last-child {
    margin-bottom: 0;
}

/* =========================================================
   PANEL HEADER: título a la izquierda, acciones a la derecha
   Da aire entre el título y los botones del encabezado
   ========================================================= */
.panel-header,
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* El grupo de botones del header mantiene separación entre sí */
.panel-header .d-flex.gap-2,
.card-header .d-flex.gap-2 {
    gap: 8px !important;
}

/* =========================================================
   ESPACIADO ENTRE SECCIONES (agregar al final de main.css)
   Da "aire" entre paneles, cards y secciones consecutivas
   ========================================================= */

/* Separación por defecto entre paneles/cards consecutivos */
.app-content .panel,
.app-content .card {
    margin-bottom: 24px;
}
.app-content .panel:last-child,
.app-content .card:last-child {
    margin-bottom: 0;
}

/* Grids de tarjetas y filas con separación inferior */
.app-content .stats-grid {
    margin-bottom: 24px;
}

/* Bloques sueltos comunes en las páginas */
.app-content .alert {
    margin-bottom: 24px;
}

/* Contenedores en grid (ficha-grid, dash-grid, form-row usados como layout)
   no deben perder el gap interno, pero sí separar del bloque siguiente */
.app-content .ficha-grid,
.app-content .dash-grid {
    margin-bottom: 24px;
}

/* Dentro de columnas de un grid, los paneles apilados también se separan */
.ficha-grid > div > .panel,
.dash-grid > div > .panel {
    margin-bottom: 16px;
}
.ficha-grid > div > .panel:last-child,
.dash-grid > div > .panel:last-child {
    margin-bottom: 0;
}

/* =========================================================
   PANEL HEADER: título a la izquierda, acciones a la derecha
   Da aire entre el título y los botones del encabezado
   ========================================================= */
.panel-header,
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* El grupo de botones del header mantiene separación entre sí */
.panel-header .d-flex.gap-2,
.card-header .d-flex.gap-2 {
    gap: 8px !important;
}

/* =========================================================
   FIX RADIO CORTADO en el encabezado del panel
   El fondo del .panel-header es cuadrado y tapa la esquina
   redondeada del .panel. Se redondean las esquinas superiores
   del header para que sigan la curva del panel.
   ========================================================= */
.panel > .panel-header:first-child,
.card > .card-header:first-child {
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}

/* Si el primer hijo del panel es una tabla o body, redondear arriba */
.panel > .data-table-wrapper:first-child,
.panel > .panel-body:first-child {
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}

/* Último elemento del panel: redondear esquinas inferiores */
.panel > .panel-footer:last-child,
.panel > .panel-body:last-child,
.panel > .data-table-wrapper:last-child {
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

/* ═══ CORREGIR AUTOFILL/autocomplete ═══ */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
textarea:-webkit-autofill:active,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus,
select:-webkit-autofill:active {
    -webkit-text-fill-color: var(--text-main) !important;
    -webkit-box-shadow: 0 0 0px 1000px var(--bg-input) inset !important;
    transition: background-color 5000s ease-in-out 0s !important;
    caret-color: var(--text-main) !important;
}

/* Para modo oscuro */
body.dark-mode input:-webkit-autofill,
body.dark-mode input:-webkit-autofill:hover,
body.dark-mode input:-webkit-autofill:focus,
body.dark-mode input:-webkit-autofill:active,
body.dark-mode textarea:-webkit-autofill,
body.dark-mode textarea:-webkit-autofill:hover,
body.dark-mode textarea:-webkit-autofill:focus,
body.dark-mode textarea:-webkit-autofill:active {
    -webkit-text-fill-color: var(--text-main) !important;
    -webkit-box-shadow: 0 0 0px 1000px var(--bg-card) inset !important;
}

/* Forzar color de texto en todos los inputs */
input,
textarea,
select {
    color: var(--text-main) !important;
    background-color: var(--bg-input) !important;
}

/* Asegurar que el placeholder sea visible */
input::placeholder,
textarea::placeholder {
    color: var(--text-muted) !important;
    opacity: 1 !important;
}

/* Input enfocado */
input:focus,
textarea:focus,
select:focus {
    color: var(--text-main) !important;
    background-color: var(--bg-input) !important;
    border-color: var(--primary) !important;
}
/* ═══════════════════════════════════════════════════════
   NUCLEAR FIX - MATA TODO OVERRIDE
   Se aplica DESPUÉS de todo lo demás
   ═══════════════════════════════════════════════════════ */

/* Mata dark mode en tiempo real */
@media (prefers-color-scheme: dark) {
    :root, html, body, body.dark-mode, [data-theme="dark"] {
        --primary: #0D4C99 !important;
        --primary-dark: #003580 !important;
        --success: #16a34a !important;
        --danger: #dc2626 !important;
        --warning: #d97706 !important;
        --info: #0891b2 !important;
    }

    .btn-primary {
        background-color: #0D4C99 !important;
        border-color: #0D4C99 !important;
        color: #fff !important;
    }

    .btn-success {
        background-color: #16a34a !important;
        border-color: #16a34a !important;
        color: #fff !important;
    }

    .btn-danger {
        background-color: #dc2626 !important;
        border-color: #dc2626 !important;
        color: #fff !important;
    }
}

/* Colores SIEMPRE hardcodeados en cualquier estado */
.btn-primary,
button.btn-primary,
a.btn-primary,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary:visited {
    background-color: #0D4C99 !important;
    border-color: #0D4C99 !important;
    color: #ffffff !important;
}

.btn-success,
button.btn-success,
a.btn-success,
.btn-success:hover,
.btn-success:focus,
.btn-success:active {
    background-color: #16a34a !important;
    border-color: #16a34a !important;
    color: #ffffff !important;
}

.btn-danger,
button.btn-danger,
a.btn-danger,
.btn-danger:hover,
.btn-danger:focus,
.btn-danger:active {
    background-color: #dc2626 !important;
    border-color: #dc2626 !important;
    color: #ffffff !important;
}

.btn-warning,
button.btn-warning,
a.btn-warning,
.btn-warning:hover,
.btn-warning:focus,
.btn-warning:active {
    background-color: #d97706 !important;
    border-color: #d97706 !important;
    color: #ffffff !important;
}

.btn-info,
button.btn-info,
a.btn-info,
.btn-info:hover,
.btn-info:focus,
.btn-info:active {
    background-color: #0891b2 !important;
    border-color: #0891b2 !important;
    color: #ffffff !important;
}

/* ═════════════════════════════════════════════════════════════
   RESPONSIVE FIX - MOBILE FIRST
   Ajustes para que se vea bien en celular
   ═════════════════════════════════════════════════════════════ */

/* TABLET Y MÁS PEQUEÑO */
@media (max-width: 1024px) {
    .panel-header {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .panel-header .d-flex {
        flex-wrap: wrap;
    }
}

/* MOBILE - PANTALLAS PEQUEÑAS */
@media (max-width: 768px) {
    /* HEADERS CON BOTONES */
    .panel-header,
    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }
    
    /* BUSCADOR FULL WIDTH */
    .panel-header .form-control,
    .panel-header .input-group {
        width: 100% !important;
    }
    
    /* BOTONES EN FILA, RESPONSIVE */
    .panel-header .d-flex.gap-2,
    .panel-header .btn-group,
    .card-header .d-flex.gap-2 {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px !important;
    }
    
    .panel-header .btn,
    .panel-header .btn-primary,
    .panel-header .btn-success {
        flex: 1;
        min-width: 120px;
        white-space: nowrap;
        font-size: 12px;
        padding: 8px 12px !important;
    }
    
    /* TABLA RESPONSIVE */
    .data-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table-wrapper table {
        font-size: 12px;
    }
    
    table th,
    table td {
        padding: 8px 6px !important;
        font-size: 12px !important;
    }
    
    table th {
        font-size: 11px;
        font-weight: 600;
    }
    
    /* OCULTAR COLUMNAS NO ESENCIALES EN MOBILE */
    table th:nth-child(4),
    table td:nth-child(4),
    table th:nth-child(5),
    table td:nth-child(5) {
        display: none;
    }
    
    /* ÍCONOS MÁS PEQUEÑOS */
    .btn-sm {
        padding: 4px 6px !important;
        font-size: 12px !important;
    }
    
    .btn i {
        font-size: 14px !important;
    }
    
    /* CARDS Y PANELES */
    .panel,
    .card {
        border-radius: var(--radius-sm);
        margin-bottom: 16px;
    }
    
    .panel-header,
    .panel-body,
    .card-header,
    .card-body {
        padding: 12px !important;
    }
    
    /* AVATARES Y FOTOS MÁS PEQUEÑOS */
    img[class*="avatar"],
    .profile-pic,
    table img {
        width: 32px !important;
        height: 32px !important;
    }
}

/* MOBILE EXTRA PEQUEÑO */
@media (max-width: 480px) {
    .panel-header .btn,
    .panel-header .btn-primary,
    .panel-header .btn-success {
        min-width: 100px;
        padding: 6px 10px !important;
        font-size: 11px;
    }
    
    table th,
    table td {
        padding: 6px 4px !important;
        font-size: 11px !important;
    }
    
    .panel-header,
    .panel-body,
    .card-header,
    .card-body {
        padding: 10px !important;
    }
    
    /* TÍTULOS MÁS PEQUEÑOS */
    .panel-header h1,
    .card-header h1,
    h2 {
        font-size: 16px !important;
    }
}
/* =========================================================
   KPI STATS EN MÓVIL — 2x2 tipo tarjeta
   ========================================================= */
@media (max-width: 576px) {

  /* Forzar 2 columnas (el minmax de 220px ya no manda) */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
  }

  /* Card vertical, centrada, cuadrada */
  .stats-grid .stat-card {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
    padding: 16px 10px;
    min-width: 0;          /* evita desbordes en grid */
  }

  .stats-grid .stat-icon {
    width: 44px;
    height: 44px;
    font-size: 20px;
    border-radius: 12px;
  }

  .stats-grid .stat-info h3 { font-size: 22px; }
  .stats-grid .stat-info p  { font-size: 11px; margin-top: 2px; }
}
/* ═══════════════════════════════════════════════════════════
   FIX CHECKBOX / RADIO  (2026-07-22)
   La regla global  input{ background-color: var(--bg-input) !important }
   pinta el fondo del estado :checked con el color de input (casi blanco
   en tema claro), dejando el tick (SVG blanco de Bootstrap) INVISIBLE.
   Restauramos: base limpia + fondo de marca = color primario del tema,
   para que el ✓ / ● blanco se vea. Cubre light, dark y alto contraste.
   ═══════════════════════════════════════════════════════════ */
/* Base: cuadradito / círculo con fondo limpio del tema */
input[type="checkbox"],
input[type="radio"] {
    background-color: var(--bg-card) !important;
}
/* Marcado: fondo = primario del tema → el tick blanco de Bootstrap se ve */
input[type="checkbox"]:checked,
input[type="radio"]:checked {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
}
input[type="checkbox"]:checked:focus,
input[type="radio"]:checked:focus {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
}
/* Alto contraste: el primario es cyan y el tick blanco no se vería;
   forzamos fondo negro (tick blanco visible) con borde cyan/visible */
body.high-contrast input[type="checkbox"],
body.high-contrast input[type="radio"],
[data-theme="contrast"] input[type="checkbox"],
[data-theme="contrast"] input[type="radio"] {
    border-color: #ffffff !important;
}
body.high-contrast input[type="checkbox"]:checked,
body.high-contrast input[type="radio"]:checked,
[data-theme="contrast"] input[type="checkbox"]:checked,
[data-theme="contrast"] input[type="radio"]:checked {
    background-color: #000000 !important;
    border-color: #00ffff !important;
}
/* ═══ Dashboard standalone ═══ */
.nav-link-dashboard {
    font-weight: 600;
}

.sidebar-divider {
    border: none;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.08));
    margin: 8px 16px 4px;
}
/* =========================================================
MEJORAS MÓVILES - ASISTENCIA (AGREGAR AL FINAL DE main.css)
========================================================= */

/* 1. HEADER DE ACCIONES OPTIMIZADO */
@media (max-width: 768px) {
    /* Apilar header */
    .asis-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    /* Grid de botones: 1 columna para el principal, 2 para los secundarios */
    .asis-header__actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        width: 100%;
    }

    /* Botón "Registrar Asistencia" ocupa todo el ancho arriba */
    .asis-header__actions .btn-success {
        grid-column: 1 / -1;
        padding: 12px !important;
        font-size: 1rem;
        justify-content: center;
    }

    /* Botones secundarios (Reportes y Cierre) */
    .asis-header__actions .btn-outline-primary,
    .asis-header__actions .btn-warning {
        padding: 10px 5px !important;
        font-size: 0.85rem;
        white-space: normal;
        line-height: 1.2;
        height: auto;
        min-height: 44px; /* Tamaño táctil */
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }
}

/* 2. TABS DE NAVEGACIÓN */
.asistencia-tabs-nav {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    /* Ocultar scrollbar pero permitir scroll */
    scrollbar-width: none; 
    -ms-overflow-style: none;
}
.asistencia-tabs-nav::-webkit-scrollbar { 
    display: none; 
}

@media (max-width: 768px) {
    .asistencia-nav-tab {
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* 3. FILTRO DE PERÍODO (STACK VERTICAL) */
@media (max-width: 768px) {
    .filtro-periodo {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .filtro-presets {
        overflow-x: auto;
        padding-bottom: 8px;
        white-space: nowrap;
        scrollbar-width: none;
    }
    .filtro-presets::-webkit-scrollbar { display: none; }

    .filtro-rango {
        display: grid;
        grid-template-columns: 1fr 1fr; /* Desde y Hasta */
        gap: 10px;
        align-items: end;
    }
    
    .filtro-rango button {
        grid-column: 1 / -1; /* Botón Aplicar abajo del todo */
        width: 100%;
        justify-content: center;
        padding: 10px;
    }
    
    .filtro-rango span {
        display: none; /* Ocultar la "a" entre fechas en móvil muy chico */
    }
}

/* 4. TRANSFORMACIÓN DE TABLAS A TARJETAS (CARD VIEW) */
@media (max-width: 768px) {
    /* Ocultar cabecera de tabla tradicional */
    .data-table thead {
        display: none;
    }

    /* La fila se convierte en una tarjeta */
    .data-table tbody tr {
        display: block;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        margin-bottom: 16px;
        padding: 16px;
        box-shadow: var(--shadow-xs);
    }

    /* Las celdas se apilan */
    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 0;
        border-bottom: 1px solid var(--border-color);
        text-align: right;
        font-size: 14px;
    }

    .data-table td:last-child {
        border-bottom: none;
    }

    /* ETIQUETAS: Usamos el atributo data-label que agregaremos en el PHP */
    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        margin-right: 16px;
        text-align: left;
    }

    /* ESTILO ESPECIAL PARA LA PRIMERA COLUMNA (Nombre del Curso/Alumno) */
    /* Esta será el "Título" de la tarjeta */
    .data-table td:first-child {
        flex-direction: column;
        align-items: flex-start;
        border-bottom: 2px solid var(--border-color);
        margin-bottom: 12px;
        padding-bottom: 12px;
        text-align: left;
    }
    
    .data-table td:first-child::before {
        display: none; /* No mostrar etiqueta "Curso" o "Alumno" redundante */
    }
    
    .data-table td:first-child strong {
        font-size: 1.1rem;
        color: var(--text-main);
        margin-bottom: 4px;
    }

    /* AJUSTE PARA BARRAS DE PROGRESO (Columna de %) */
    /* Si la celda contiene un div complejo, lo hacemos full width */
    .data-table td .d-flex {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Ajuste específico para pantallas muy pequeñas (iPhone SE) */
@media (max-width: 380px) {
    .filtro-rango {
        grid-template-columns: 1fr; /* Fechas una debajo de otra */
    }
    .data-table td {
        font-size: 13px;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .data-table td::before {
        font-size: 11px;
        text-transform: uppercase;
    }
}
