/* ═══════════════════════════════════════════════════════════
   UGDA — Sistema de Gestión Documental
   CSS Principal — Overrides de Bootstrap + componentes custom
   ═══════════════════════════════════════════════════════════ */

/* ─── Google Fonts: Open Sans ──────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ─── Variables CSS ────────────────────────────────────── */
:root {
    /* Primarios */
    --primary:          #00167B;
    --primary-dark:     #000F54;
    --primary-light:    #1A3BA0;
    --primary-subtle:   #E8ECFA;

    /* Acento */
    --accent:           #35D32F;
    --accent-dark:      #28A623;
    --accent-light:     #5EE05A;
    --accent-subtle:    #E8FBE7;

    /* Sidebar */
    --sidebar-bg:       #001171;
    --sidebar-hover:    rgba(255, 255, 255, 0.12);
    --sidebar-active:   rgba(255, 255, 255, 0.22);
    --sidebar-text:     #FFFFFF;
    --sidebar-text-active: #FFFFFF;
    --sidebar-width:    220px;
    --sidebar-collapsed-width: 70px;

    /* Superficies */
    --bg-body:          #F0F2F5;
    --bg-white:         #FFFFFF;
    --bg-card:          #FFFFFF;

    /* Texto */
    --text-primary:     #1E2A3A;
    --text-secondary:   #6B7A99;
    --text-muted:       #94A3B8;

    /* Bordes */
    --border-color:     #E2E8F0;
    --border-radius:    0.5rem;
    --border-radius-lg: 12px;

    /* Sombras */
    --shadow-sm:        0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow:           0 4px 16px rgba(0, 0, 0, 0.09);
    --shadow-md:        0 6px 20px rgba(0, 0, 0, 0.12);
    --shadow-lg:        0 12px 32px rgba(0, 0, 0, 0.14);

    /* Topbar */
    --topbar-height:    60px;

    /* Transiciones */
    --transition:       all 0.2s ease;
    --transition-slow:  all 0.3s ease;
}

/* ─── Base ─────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ─── Override Bootstrap Colors ────────────────────────── */
.btn-primary {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    box-shadow: none !important;
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-light) !important;
    border-color: var(--primary-light) !important;
    box-shadow: none !important;
}

.btn-success {
    background-color: var(--accent) !important;
    border-color: var(--accent) !important;
}
.btn-success:hover, .btn-success:focus {
    background-color: var(--accent-dark) !important;
    border-color: var(--accent-dark) !important;
}

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

.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }

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

/* Focus ring override */
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 0.2rem rgba(0, 22, 123, 0.15);
}

/* ─── Layout Principal ─────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ──────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: var(--transition-slow);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--sidebar-hover);
    border-radius: 4px;
}

/* ─── Sidebar Brand ─────────────────────────────────────── */
.sidebar-brand {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: var(--topbar-height);
    overflow: hidden;
}

.sidebar-brand-logo {
    height: 36px;
    width: auto;
    display: block;
    object-fit: contain;
}

.sidebar-brand-isotipo {
    height: 36px;
    width: auto;
    display: none;
    object-fit: contain;
}

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

.sidebar-section {
    padding: 0.4rem 1.5rem;
    margin-top: 0.25rem;
}

.sidebar-section-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.45);
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.5rem;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 400;
    transition: var(--transition);
    border-radius: 0;
    position: relative;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    font-weight: 500;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.sidebar-link .material-symbols-outlined {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    color: #FFFFFF;
}

/* ─── Sidebar Dropdowns ────────────────────────────────── */
.sidebar-dropdown {
    display: flex;
    flex-direction: column;
}

.sidebar-dropdown-toggle {
    cursor: pointer;
}

.sidebar-dropdown-toggle .dropdown-chevron {
    margin-left: auto;
    transition: var(--transition);
    font-size: 1rem !important;
    opacity: 0.55;
    color: #FFFFFF;
}

.sidebar-dropdown.open .dropdown-chevron {
    transform: rotate(180deg);
    opacity: 1;
}

.sidebar-dropdown-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0, 0, 0, 0.18);
}

.sidebar-dropdown.open .sidebar-dropdown-menu {
    max-height: 1000px;
}

.sidebar-dropdown-menu .sidebar-link {
    padding-left: 2.75rem;
    font-size: 0.88rem;
    color: rgba(255,255,255,0.78);
}

.sidebar-dropdown-menu .sidebar-link .material-symbols-outlined {
    font-size: 1.1rem;
    width: 20px;
    opacity: 0.85;
}

.sidebar-dropdown-menu .sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-dropdown-menu .sidebar-link.active {
    color: #fff;
}

.sidebar-dropdown-menu .sidebar-link.active::before {
    left: 0;
}

.sidebar-tutorial-link {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 16px 10px;
    padding: 7px 12px;
    border-radius: 6px;
    background: transparent;
    position: relative;
    border: none;
    color: rgba(255,255,255,0.45);
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    transition: color .18s;
}

.sidebar-tutorial-link:hover {
    color: rgba(255,255,255,0.8);
}

.sidebar-tutorial-link .material-symbols-outlined {
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-tutorial-link span:last-child {
    display: none;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 0.8rem;
    color: rgba(255,255,255,0.35);
    text-align: center;
}

/* ─── Sidebar Collapsed State ──────────────────────────── */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    overflow: visible;
}

.sidebar.collapsed .sidebar-brand-logo {
    display: none;
}

.sidebar.collapsed .sidebar-brand-isotipo {
    display: block;
}

.sidebar.collapsed .sidebar-section {
    display: none;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 0.75rem 0;
}

.sidebar.collapsed .sidebar-link .sidebar-link-text {
    display: none;
}

/* Textos visibles DENTRO del flyout */
.sidebar.collapsed .sidebar-dropdown:hover .sidebar-dropdown-menu .sidebar-link-text {
    display: inline !important;
}

.sidebar.collapsed .sidebar-link .dropdown-chevron {
    display: none;
}

.sidebar.collapsed .sidebar-dropdown-menu {
    display: none !important;
    max-height: 0 !important;
}

.sidebar.collapsed .sidebar-footer {
    display: none;
}

/* ─── Collapsed Flyout (hover panel) ───────────────────── */
.sidebar.collapsed .sidebar-dropdown {
    position: relative;
}

.sidebar.collapsed .sidebar-dropdown:hover > .sidebar-dropdown-menu {
    display: flex !important;
    flex-direction: column;
    max-height: none !important;
    position: fixed;
    left: var(--sidebar-collapsed-width);
    top: auto;
    background: #001171;
    min-width: 220px;
    padding: 0.5rem 0;
    z-index: 1050;
    box-shadow: 6px 4px 20px rgba(0, 0, 0, 0.35);
    border-left: 3px solid var(--accent);
    border-radius: 0 0.5rem 0.5rem 0;
    animation: flyoutFadeIn 0.15s ease;
}

.sidebar.collapsed .sidebar-dropdown:hover .sidebar-dropdown-toggle {
    background: var(--sidebar-hover);
}

.sidebar.collapsed .sidebar-dropdown-menu::before {
    content: attr(data-label);
    display: block;
    padding: 0.6rem 1rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.45);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 0.25rem;
}

.sidebar.collapsed .sidebar-dropdown-menu .sidebar-link {
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.85);
    justify-content: flex-start;
}

@keyframes flyoutFadeIn {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ─── Collapsed Tooltips (links directos) ───────────────── */
.sidebar.collapsed .sidebar-nav > a.sidebar-link[data-tooltip]::after,
.sidebar.collapsed .sidebar-tutorial-link[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    background: #001171;
    color: rgba(255,255,255,0.92);
    padding: 0.45rem 1.4rem;
    border-left: 3px solid var(--accent);
    border-radius: 0 0.5rem 0.5rem 0;
    white-space: nowrap;
    font-size: 0.88rem;
    font-weight: 500;
    z-index: 1050;
    box-shadow: 6px 4px 20px rgba(0,0,0,0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.sidebar.collapsed .sidebar-nav > a.sidebar-link[data-tooltip]:hover::after,
.sidebar.collapsed .sidebar-tutorial-link[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.main-content.collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

/* ─── Topbar ───────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: var(--transition-slow);
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-sm);
}

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

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-secondary);
    display: block;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}

.page-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.topbar-create-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    transition: var(--transition);
    flex-shrink: 0;
}

.topbar-create-btn:hover {
    background: var(--primary-dark);
    color: #fff;
}

.topbar-create-btn .material-symbols-outlined {
    font-size: 1rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.35rem 0.75rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.topbar-user:hover {
    background: var(--bg-body);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-info {
    text-align: right;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.user-role {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ─── User Dropdown ────────────────────────────────────── */
.user-dropdown {
    position: relative;
}

.user-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 0.5rem 0;
    display: none;
    z-index: 1050;
}

.user-dropdown-menu.show {
    display: block;
    animation: fadeInDown 0.15s ease;
}

.user-dropdown-menu a,
.user-dropdown-menu button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
    border: none;
    background: none;
    width: 100%;
    cursor: pointer;
}

.user-dropdown-menu a:hover,
.user-dropdown-menu button:hover {
    background: var(--bg-body);
}

.user-dropdown-divider {
    border-top: 1px solid var(--border-color);
    margin: 0.25rem 0;
}

/* ─── Búsqueda Global (topbar) ─────────────────────────── */

.gs-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1.5rem;
    position: relative;
}

.gs-input-group {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 480px;
    height: 38px;
    border: 1.5px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-body);
    padding: 0 0.75rem;
    transition: var(--transition);
    gap: 0.4rem;
}

.gs-input-group:focus-within {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 22, 123, 0.08);
}

.gs-icon {
    font-size: 1.1rem;
    color: var(--text-muted);
    flex-shrink: 0;
    pointer-events: none;
    transition: color 0.15s;
}

.gs-input-group:focus-within .gs-icon {
    color: var(--primary);
}

.gs-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.85rem;
    color: var(--text-primary);
    font-family: inherit;
    min-width: 0;
}

.gs-input::placeholder {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.gs-clear {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color 0.15s;
}

.gs-clear:hover {
    color: var(--text-primary);
}

.gs-mobile-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    color: var(--text-secondary);
    align-items: center;
}

.gs-dropdown {
    position: fixed;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1060;
    overflow: hidden;
    max-height: 480px;
    overflow-y: auto;
    min-width: 320px;
}

.gs-group-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    background: #F8FAFC;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
}

.gs-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 1rem;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #F8FAFC;
    transition: background 0.15s;
}

.gs-item:last-child {
    border-bottom: none;
}

.gs-item:hover,
.gs-item.active {
    background: var(--primary-subtle);
    text-decoration: none;
    color: inherit;
}

.gs-badge {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gs-badge.exp { background: #DBEAFE; color: #1D4ED8; }
.gs-badge.pre { background: #FEF3C7; color: #D97706; }
.gs-badge.tra { background: #F3E8FF; color: #7C3AED; }
.gs-badge.inc { background: #FEE2E2; color: #DC2626; }

.gs-item-body {
    flex: 1;
    min-width: 0;
}

.gs-item-code {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gs-item-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gs-tipo-tag {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    color: #fff;
    flex-shrink: 0;
    vertical-align: middle;
}

.gs-tipo-tag.exp { background: #3B82F6; }
.gs-tipo-tag.pre { background: #F59E0B; }
.gs-tipo-tag.tra { background: #8B5CF6; }
.gs-tipo-tag.inc { background: #EF4444; }

.gs-loading,
.gs-empty,
.gs-error {
    padding: 1.25rem 1rem;
    text-align: center;
    font-size: 0.83rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.gs-footer {
    padding: 0.55rem 1rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    background: #F8FAFC;
}

.gs-footer a {
    font-size: 0.78rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.gs-footer a:hover {
    text-decoration: underline;
}

@media (max-width: 767.98px) {
    .gs-wrap {
        flex: 0;
        padding: 0;
    }

    .gs-input-group {
        display: none;
    }

    .gs-mobile-btn {
        display: flex;
    }

    .gs-wrap.mobile-open {
        flex: 1;
        padding: 0 0.5rem;
    }

    .gs-wrap.mobile-open .gs-input-group {
        display: flex;
        max-width: 100%;
    }

    .gs-wrap.mobile-open .gs-mobile-btn {
        display: none;
    }
}

/* ─── Contenido ────────────────────────────────────────── */
.content-area {
    flex: 1;
    padding: 1.5rem;
}

/* ─── Cards ────────────────────────────────────────────── */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* ─── Stats Cards (Dashboard) ──────────────────────────── */
.stat-card {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon .material-symbols-outlined {
    font-size: 1.5rem;
    color: #fff;
}

.stat-icon.bg-primary-subtle { background: var(--primary); }
.stat-icon.bg-accent-subtle { background: var(--accent); }
.stat-icon.bg-info-subtle { background: #3B82F6; }
.stat-icon.bg-warning-subtle { background: #F59E0B; }

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ─── Tablas ───────────────────────────────────────────── */
.table-wrapper {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-header {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 0.75rem;
    background: var(--bg-white);
}

.table-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.table {
    margin-bottom: 0;
}

/* Header azul institucional */
.table thead th {
    background: var(--primary);
    border-bottom: none;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #FFFFFF;
    padding: 0.85rem 1rem;
    white-space: nowrap;
}

/* Separadores grises entre filas */
.table tbody td {
    padding: 0.8rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #F0F4F8;
    font-size: 0.9rem;
}

.table tbody tr {
    border-bottom: 1px solid #F0F4F8;
    transition: background 0.15s;
}

.table tbody tr:hover {
    background-color: rgba(0, 22, 123, 0.03);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Zebra stripes — forzadas con !important para sobreescribir DataTables */
.table-wrapper .table tbody tr:nth-child(even) td,
.table-wrapper .table tbody tr:nth-child(even) {
    background-color: #F2F2F2 !important;
}
.table-wrapper .table tbody tr:nth-child(odd) td,
.table-wrapper .table tbody tr:nth-child(odd) {
    background-color: #FFFFFF !important;
}
/* Hover: sin cambio en ninguna fila */
.table-wrapper .table tbody tr:nth-child(even):hover td,
.table-wrapper .table tbody tr:nth-child(even):hover {
    background-color: #F2F2F2 !important;
}
.table-wrapper .table tbody tr:nth-child(odd):hover td,
.table-wrapper .table tbody tr:nth-child(odd):hover {
    background-color: #FFFFFF !important;
}

/* DataTables - override header sort arrows to white */
.table thead th.sorting::after,
.table thead th.sorting_asc::after,
.table thead th.sorting_desc::after,
.table thead th.sorting::before,
.table thead th.sorting_asc::before,
.table thead th.sorting_desc::before {
    color: rgba(255,255,255,0.7) !important;
}

/* ─── Badges de estado ─────────────────────────────────── */
.badge-estado {
    padding: 0.3rem 0.65rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.badge-estado.activo {
    background: var(--accent-subtle);
    color: var(--accent-dark);
}

.badge-estado.inactivo {
    background: #F1F5F9;
    color: #64748B;
}

/* ─── Formularios ──────────────────────────────────────── */
.form-card {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.form-card .card-header {
    padding: 1.25rem 1.5rem;
}

.form-card .card-body {
    padding: 1.5rem;
}

.form-label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
}

.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    transition: var(--transition);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-text {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ─── Breadcrumb ───────────────────────────────────────── */
.breadcrumb-wrapper {
    padding: 0;
    margin-bottom: 0.75rem;
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.breadcrumb-item a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s;
}

.breadcrumb-item a:hover {
    color: var(--primary);
}

.breadcrumb-item.active {
    color: var(--primary);
    font-weight: 600;
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-muted);
}

/* ─── Page header layout (breadcrumb + btn) ─────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-header-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.page-header-right {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 0.5rem;
}

/* ─── Flash Messages / Alerts ──────────────────────────── */
.flash-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    max-width: 420px;
    width: 100%;
}

.flash-message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius-lg);
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    border-left: 4px solid;
}

.flash-message.flash-success {
    background: #F0FDF4;
    border-left-color: #22C55E;
    color: #166534;
}

.flash-message.flash-error {
    background: #FEF2F2;
    border-left-color: #EF4444;
    color: #991B1B;
}

.flash-message.flash-warning {
    background: #FFFBEB;
    border-left-color: #F59E0B;
    color: #92400E;
}

.flash-message.flash-info {
    background: #EFF6FF;
    border-left-color: #3B82F6;
    color: #1E40AF;
}

.flash-close {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    font-size: 1.1rem;
    margin-left: auto;
    padding: 0;
    line-height: 1;
}

.flash-close:hover {
    opacity: 1;
}

/* ─── Action Buttons ───────────────────────────────────── */
.btn-action {
    padding: 0.4rem 0.55rem;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-action .material-symbols-outlined {
    font-size: 1.25rem;
}

.btn-action-edit {
    background: var(--primary-subtle);
    color: var(--primary);
}
.btn-action-edit:hover {
    background: var(--primary);
    color: #fff;
}

.btn-action-delete {
    background: #FEE2E2;
    color: #EF4444;
}
.btn-action-delete:hover {
    background: #EF4444;
    color: #fff;
}

/* Botón inhabilitar (reemplaza eliminar) */
.btn-action-disable {
    background: #FFF3E0;
    color: #E65100;
}
.btn-action-disable:hover {
    background: #E65100;
    color: #fff;
}

.btn-action-enable {
    background: var(--accent-subtle);
    color: var(--accent-dark);
}
.btn-action-enable:hover {
    background: var(--accent-dark);
    color: #fff;
}

.btn-action-view {
    background: #E0F2FE;
    color: #3B82F6;
}
.btn-action-view:hover {
    background: #3B82F6;
    color: #fff;
}

/* ─── DataTables Override ──────────────────────────────── */
.dataTables_wrapper {
    padding-top: 0.85rem;
}
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    padding-bottom: 0.65rem;
}
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.35rem 2rem 0.35rem 0.75rem;
    font-size: 0.85rem;
    width: auto;
    display: inline-block;
}
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 0.2rem rgba(0, 22, 123, 0.15);
    outline: none;
}

.dataTables_wrapper .dataTables_info {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-top: 0.75rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--border-radius) !important;
    margin: 0 2px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary-subtle) !important;
    border-color: var(--primary-subtle) !important;
    color: var(--primary) !important;
}

/* Override for Bootstrap 5 Pagination (used by DataTables BS5 integration) */
.pagination .page-item.active .page-link {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}

.pagination .page-link {
    color: var(--text-secondary);
}

.pagination .page-link:hover {
    color: var(--primary);
    background-color: var(--primary-subtle);
    border-color: #dee2e6;
}

.pagination .page-link:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 22, 123, 0.15);
}

/* ─── Login Page ───────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    position: relative;
    overflow: hidden;
}

.login-deco {
    position: absolute;
    pointer-events: none;
    user-select: none;
}

/* elemento1 cubre todo el fondo como capa decorativa */
.login-deco-1 {
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0.13;
}

/* elemento2 en esquina superior-derecha */
.login-deco-2 {
    top: -20px;
    right: -20px;
    width: 520px;
    opacity: 0.22;
}

.login-card {
    background: rgba(255, 255, 255);
    backdrop-filter: blur(20px);
    border-radius: 1rem;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    position: relative;
    z-index: 1;
}

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

.login-logo img {
    max-height: 100px;
    max-width: 260px;
    margin-bottom: 0.75rem;
    object-fit: contain;
}

.login-logo h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 3px;
    margin: 0;
}

.login-logo p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0;
}

.login-form .form-label {
    font-weight: 500;
}

.login-form .input-group-text {
    background: var(--bg-body);
    border-right: none;
    color: var(--text-muted);
}

.login-form .form-control {
    border-left: none;
}

.login-form .form-control:focus {
    box-shadow: none;
}

.login-form .input-group:focus-within {
    box-shadow: 0 0 0 0.2rem rgba(0, 22, 123, 0.15);
    border-radius: var(--border-radius);
}

.login-form .input-group:focus-within .input-group-text {
    border-color: var(--primary-light);
}

.login-form .input-group:focus-within .form-control {
    border-color: var(--primary-light);
}

.login-form .remember-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.55rem;
    margin-top: 1.55rem;
}

.login-form .remember-row .form-check-input {
    width: 1rem;
    height: 1rem;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    border: 2px solid var(--primary);
    border-radius: 0.25rem;
    background-color: #fff;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    position: relative;
}

.login-form .remember-row .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.login-form .remember-row .form-check-input:checked::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M3 8l3.5 3.5L13 4.5'/%3E%3C/svg%3E") center/contain no-repeat;
}

.login-form .remember-row .form-check-input:focus {
    outline: none;
    box-shadow: 0 0 0 0.15rem rgba(0, 22, 123, 0.2);
}

.login-form .remember-row .form-check-label {
    cursor: pointer;
    font-size: 0.83rem;
    color: var(--text-muted);
    line-height: 1;
    user-select: none;
}

.login-btn {
    width: 100%;
    padding: 0.65rem;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ─── Empty State ──────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state .material-symbols-outlined {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state p {
    margin: 0;
    font-size: 0.95rem;
}

/* ─── Animaciones ──────────────────────────────────────── */
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

@keyframes fadeInDown {
    from { transform: translateY(-8px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ─── Responsive ───────────────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1035;
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .main-content.collapsed {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }
}

@media (max-width: 575.98px) {
    .content-area {
        padding: 1rem;
    }

    .topbar {
        padding: 0 1rem;
    }

    .user-info {
        display: none;
    }

    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-card {
        padding: 1rem;
    }

    .login-card {
        margin: 1rem;
        padding: 1.5rem;
    }
}

/* ─── Utilidades ───────────────────────────────────────── */
.gap-05 { gap: 0.5rem; }
.gap-1 { gap: 1rem; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.85rem; }
.text-muted-custom { color: var(--text-muted); }

/* Material Symbols sizing */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
}

.icon-sm { font-size: 1rem !important; }
.icon-md { font-size: 1.25rem !important; }
.icon-lg { font-size: 1.5rem !important; }
