:root {
    --primary: #1e3a8a;
    --primary-light: #3b82f6;
    --secondary: #64748b;
    --accent: #10b981;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --radius: 12px;
    --sidebar-w: 260px;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', 'Open Sans', sans-serif;
    margin: 0;
    line-height: 1.6;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Navbar & Sidebar Header */
.navbar-default {
    background: var(--bg-card);
    border: none;
    box-shadow: var(--shadow-sm);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1030; /* Below sidebar and modals */
}

.navbar-default .container-fluid {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hamburger-btn {
    font-size: 20px;
    color: var(--primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.hamburger-btn:hover {
    background: #eff6ff;
}

/* Sidebar */
.sidenav {
    height: 100%;
    width: 0;
    position: fixed;
    z-index: 1035; /* Above navbar (1030), below modal backdrop (1040) */
    top: 0;
    left: 0;
    background-color: var(--primary);
    overflow-x: hidden;
    transition: 0.3s;
    padding-top: 60px;
    border-right: none;
}

.sidenav-header {
    padding: 14px 24px 32px 24px;
    text-align: center;
}

.sidenav-header h2 {
    color: var(--primary-text);
    font-size: 20px;
    letter-spacing: 1px;
    margin: 0;
}

.sidenav-links {
    padding: 0 16px;
    flex-grow: 1;
}

.sidenav a {
    padding: 14px 16px;
    text-decoration: none;
    font-size: 15px;
    color: var(--primary-text);
    opacity: 0.7;
    display: flex;
    align-items: center;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.sidenav a i {
    width: 24px;
    margin-right: 12px;
    font-size: 18px;
}

.sidenav a:hover {
    background: rgba(255,255,255,0.15);
    color: var(--primary-text);
    opacity: 1;
    padding-left: 20px;
}

.sidenav a.active {
    background: rgba(255,255,255,0.95);
    color: var(--primary-on-white) !important;
    opacity: 1;
    font-weight: 800;
    border-left: none;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.sidenav a.active i {
    color: var(--primary-on-white);
}

.sidenav .closebtn {
    position: absolute;
    top: 6px; /* Optimized for vertical center Y=35 */
    right: 20px;
    font-size: 32px;
    color: var(--primary-text);
    opacity: 0.8;
}

.sidenav .closebtn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.sidenav-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.disabled-dept, .disabled-user {
    
    opacity: 0.6;
}

.sidenav-footer a {
    color: var(--primary-text) !important;
    opacity: 0.8;
}

.sidenav-footer a:hover {
    opacity: 1;
}

/* Cards & Layout */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid rgba(0,0,0,0.05);
    padding: 24px;
    margin-bottom: 24px;
    transition: box-shadow 0.2s;
}


.card-title {
    font-weight: 700;
    font-size: 18px;
    color: var(--primary-on-white);
}

/* Custom Balance Cards */
.card-deck {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.card-custom-1, .card-custom-2 {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: var(--primary-text)!important;
    text-align: center;
}

.card-custom-1 .card-title, .card-custom-2 .card-title {
    color: var(--primary-text);
    opacity: 0.8;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-custom-1 .card-text, .card-custom-2 .card-text {
    font-size: 32px;
    font-weight: 800;
}

/* Lists and Tables */
.table {
    margin-bottom: 0 !important;
    margin-top: 0 !important;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 6px;
}

.table tr {
    background: white;
}

.table th {
    padding: 12px;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.table td {
    padding: 16px 12px;
    border-top: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
}

.table td:first-child { border-left: 1px solid #f1f5f9; border-radius: 8px 0 0 8px; }
.table td:last-child { border-right: 1px solid #f1f5f9; border-radius: 0 8px 8px 0; }

.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 12px;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-visto { background: #ffedd5; color: #9a3412; }
.badge-pre-aprobada { background: #fef3c7; color: #92400e; }
.badge-cancelada { background: #f1f5f9; color: #475569; }

/* Push Effect */
body {
    overflow-x: hidden;
}

#main {
    transition: margin-left .3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-pushed {
    margin-left: 260px;
    width: calc(100% - 260px) !important;
}

/* Modal Centering & Styling */
.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - (0.5rem * 2));
}

@media (min-width: 576px) {
    .modal-dialog-centered {
        min-height: calc(100% - (1.75rem * 2));
    }
}

/* Timeline Fixes (Centering) */
.timeline-icon {
    display: flex !important;
    align-items: center;
    justify-content: center;
    line-height: normal !important;
}

.timeline-icon i {
    margin: 0 !important;
    top: auto !important; /* Remove any bootstrap icon offset */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .historial-row {
        flex-direction: column;
    }
}

/* Dynamic Table & Pagination */
.dynamic-table-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px); /* Fill most of viewport */
    overflow: hidden;
    position: relative;
    border: 1px solid #e2e8f0;
}

.dynamic-table-container .table-responsive {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 0;
}

.table-pagination-footer {
    padding: 12px 24px;
    background: white; /* or #f8fafc */
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0; /* Prevent shrinking */
    
}

/* Force DataTables wrapper injected by JS to act as a Flex column */
.dataTables_wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Force the actual table to push subsequent siblings (like pagination) to the bottom */
.dataTables_wrapper .table {
    margin-bottom: auto !important;
}

/* Adjust card to use full available height if needed */
.full-height-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Scrollbar styling for table */
.table-responsive::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.table-responsive::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
.table-responsive::-webkit-scrollbar-track {
  background: #f1f5f9;
}
/* DataTables Global Premium Overrides */
.dataTables_wrapper {
    padding: 0 !important;
}

.dataTables_filter {
    padding: 16px 24px !important;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    text-align: right !important;
}

.dataTables_filter input {
    border-radius: 20px !important;
    border: 1px solid #e2e8f0 !important;
    padding: 6px 16px !important;
    font-size: 14px !important;
    width: 200px !important;
    transition: all 0.2s;
}

.dataTables_filter input:focus {
    border-color: var(--primary-light) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
    outline: none !important;
}

.dataTables_info {
    padding: 16px 24px !important;
    font-size: 13px !important;
    color: var(--text-muted) !important;
}

.dataTables_paginate {
    padding: 12px 24px !important;
    margin-bottom: 20px !important;
    text-align: center !important;
    border-top: 1px solid #f1f5f9;
    background: white !important;
    position: sticky !important;
    bottom: 0 !important;
    z-index: 100 !important;
    margin-top: auto !important; /* Forces it to the bottom of the flex container */
}


/* Clean up generic DataTables pagination to prevent conflicts */
.dataTables_paginate .paginate_button {
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

.dataTables_paginate .paginate_button:hover,
.dataTables_paginate .paginate_button:active {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* Fix for Bootstrap 3 override - Target the Anchor tag specifically */
.dataTables_wrapper .pagination {
    margin: 0 !important;
    display: flex !important;
    justify-content: center !important;
    box-shadow: none !important;
}

.dataTables_wrapper .pagination > li {
    display: inline-block;
    margin: 0 3px;
}

.dataTables_wrapper .pagination > li > a {
    margin: 0 !important;
    border: 1px solid #e2e8f0 !important;
    color: var(--text-muted) !important;
    font-weight: 700 !important;
    padding: 6px 16px !important;
    background: white !important;
    font-size: 13px !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
}

.dataTables_wrapper .pagination > li > a:hover {
    background: #f8fafc !important;
    color: var(--primary) !important;
    border-color: #cbd5e1 !important;
}

.dataTables_wrapper .pagination > .active > a,
.dataTables_wrapper .pagination > .active > a:hover {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: var(--primary-text) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
}

.dataTables_wrapper .pagination > .disabled > a {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    background: #f1f5f9 !important;
    box-shadow: none !important;
}

/* Hide DataTables Info and Length by default as requested */
.dataTables_info, .dataTables_length {
    display: none !important;
}

/* Request History Accordion Styles */
.request-item {
    background: white;
    margin-bottom: 2px !important;
    border-radius: 4px !important;
    border: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    transition: background 0.2s;
}

.request-item:last-child {
    border-bottom: none !important;
}

.request-header {
    background: transparent;
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid transparent; /* Status indicator */
    transition: background 0.2s;
}

.request-header:hover {
    background: #f8fafc;
}

.request-header[aria-expanded="true"] {
    background: #f1f5f9;
}

/* Status Colors for Borders */
.request-item[data-status="Approved"] .request-header { border-left-color: #22c55e; }
.request-item[data-status="Pre-aprobada"] .request-header { border-left-color: #f59e0b; }
.request-item[data-status="Pending"] .request-header { border-left-color: #ffc107; }
.request-item[data-status="Declined"] .request-header { border-left-color: #ef4444; }
.request-item[data-status="Canceled"] .request-header { border-left-color: #94a3b8; }

.request-body {
    padding: 20px;
    background: #f8fafc; /* Lighter background for body */
    border-top: 1px solid #e2e8f0;
}

.request-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.btn-subtle {
    background: white;
    color: var(--text-muted);
    border: 1px solid #e2e8f0;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 16px; /* Pill shape */
    transition: all 0.2s;
}

.btn-subtle:hover {
    background: #f1f5f9;
    color: var(--text-main);
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Timeline Redesign */
.request-timeline-container {
    padding: 0;
    margin-top: 24px;
    background: transparent;
    border: none;
    position: relative;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 8px; /* Space for scrollbar */
}

/* Continuous Vertical Line */
.request-timeline-container::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 20px; /* Line position */
    width: 2px;
    background: #e2e8f0;
    z-index: 0;
}

.timeline-item {
    position: relative;
    padding-left: 50px; /* Space for dot and line */
    padding-bottom: 24px;
    z-index: 1;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

/* Timeline Dot */
.timeline-dot {
    position: absolute;
    left: 11px; /* Center on line (20px line - 10px half dot width + adjustment) */
    top: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 0 2px #e2e8f0; /* Outer ring matches line color */
    background: white; /* Fallback */
    z-index: 2;
}

.timeline-dot-aprobada { background: #22c55e; box-shadow: 0 0 0 3px #dcfce7; }
.timeline-dot-rechazada, .timeline-dot-cancelada { background: #ef4444; box-shadow: 0 0 0 3px #fee2e2; }
.timeline-dot-default { background: #3b82f6; box-shadow: 0 0 0 3px #dbeafe; }

/* Timeline Text Styles */
.timeline-action {
    font-weight: 700;
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.2;
}

.timeline-time {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    margin-top: 2px;
}

.timeline-user {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.timeline-comment {
    font-size: 12px;
    color: var(--text-main);
    background: white;
    padding: 10px 14px;
    border-radius: 8px;
    margin-top: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.timeline-comment::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 20px;
    width: 10px;
    height: 10px;
    background: white;
    transform: rotate(45deg);
    border-top: 1px solid #e2e8f0;
    border-left: 1px solid #e2e8f0;
}

/* Flexbox Layout for Pagination Footer */
.historial-container {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    position: relative !important;
    border-radius: 12px;
    background: white;
}

#requests-list {
    flex: 1; /* Takes available space */
    overflow-y: auto;
    padding: 0;
    /* No bottom padding needed as pagination is separate block */
}

#requests-list::-webkit-scrollbar {
    width: 6px;
}
#requests-list::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
}

#dashRequestsTable_wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#dashRequestsTable {
    width: 100% !important;
    margin-bottom: 0 !important;
    border-bottom: none !important;
}

/* Sticky Pagination Footer for Dashboard */
#dashRequestsTable_paginate {
    position: sticky !important;
    bottom: 0 !important;
    width: 100% !important;
    min-height: 60px; /* Fixed height footer */
    background: white !important;
    border-top: 1px solid #f1f5f9;
    padding: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    z-index: 100 !important;
}

.dataTables_paginate .pagination {
    margin: 0 !important;
    justify-content: center !important;
    display: flex;
    align-items: center;
}

.dataTables_wrapper .pagination > li > a {
    border: none !important;
    background: transparent !important;
    color: var(--text-muted) !important;
    font-weight: 600;
    font-size: 13px;
    padding: 8px 14px !important;
    margin: 0 4px;
    border-radius: 8px !important;
    transition: all 0.2s;
}

.dataTables_wrapper .pagination > li.active > a {
    background: var(--primary) !important;
    color: var(--primary-text) !important;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.dataTables_wrapper .pagination > li:not(.active) > a:hover {
    background: #f8fafc !important;
    color: var(--text-main) !important;
}

/* Calendar Opacity for days of other months */
.fc-day-other {
    opacity: 0.4 !important;
}

.fc-day-other .fc-daygrid-day-number {
    opacity: 0.6;
}

/* Utilities Extracted from layout.html */
body {
    height: 100vh;
    overflow: hidden;
}
#main {
    height: calc(100% - 64px);
    overflow-y: auto;
    padding-bottom: 40px;
}
@media (max-width: 768px) {
    body {
        overflow: auto;
        max-height: none;
    }
    #main {
        height: auto;
        overflow-y: visible;
    }
}

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 16px !important; }
.mb-4 { margin-bottom: 24px !important; }
.mb-5 { margin-bottom: 48px !important; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 16px !important; }
.mt-4 { margin-top: 24px !important; }
.mt-5 { margin-top: 48px !important; }
.ml-auto { margin-left: auto !important; }
.mr-auto { margin-right: auto !important; }
.p-0 { padding: 0 !important; }
.p-1 { padding: 4px !important; }
.p-2 { padding: 8px !important; }
.p-3 { padding: 16px !important; }
.p-4 { padding: 24px !important; }
.d-flex { display: flex !important; }
.flex-column { flex-direction: column !important; }
.flex-row { flex-direction: row !important; }
.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.w-100 { width: 100% !important; }
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 16px !important; }
.password-container {
    position: relative;
}
.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-muted);
    z-index: 10;
    background: none;
    border: none;
    padding: 0;
}

/* Global Styled Alert */
#globalAlertContainer {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: 90%;
    max-width: 400px;
    pointer-events: none;
}
.styled-alert {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 5px solid var(--primary);
    animation: alertSlideIn 0.3s ease-out;
    pointer-events: all;
}
@keyframes alertSlideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.styled-alert.alert-danger { border-left-color: #ef4444; color: #991b1b; background: #fef2f2; }
.styled-alert.alert-success { border-left-color: #10b981; color: #065f46; background: #ecfdf5; }
.styled-alert.alert-warning { border-left-color: #f59e0b; color: #92400e; background: #fffbeb; }
.styled-alert-icon { font-size: 20px; }
.styled-alert-message { font-weight: 600; font-size: 14px; flex: 1; }
.styled-alert-close { cursor: pointer; opacity: 0.5; font-size: 18px; }
.styled-alert-close:hover { opacity: 1; }
