/* --- ADMIN DASHBOARD STYLES (COMPACT & OPTIMIZED) --- */

/* --- Filter Bar Styles --- */
.filter-bar {
    background-color: #f8f9fa;
}

@media (max-width: 768px) {
    .filter-bar {
        flex-direction: column;
        align-items: stretch !important;
    }
    .filter-bar .btn {
        margin-left: 0 !important;
        margin-top: 10px;
    }
    .filter-bar select, 
    .filter-bar input {
        width: 100% !important;
    }
}
/* 1. Global Layout */
.container, .admin-wrapper, .main-content {
    max-width: 1400px;
    width: 96%;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .container, .admin-wrapper, .main-content {
        width: 100%;
        padding-left: 0;
        padding-right: 0;
    }
}

/* 2. Sidebar */
.sidebar {
    width: 260px;
    height: 100vh;
    background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
    color: #ecf0f1;
    position: fixed;
    top: 0; left: 0;
    padding-top: 30px;
    z-index: 100;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Custom scrollbar styling for sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
.sidebar a {
    padding: 15px 30px;
    text-decoration: none;
    color: #bdc3c7;
    display: flex;
    align-items: center;
    transition: background 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.sidebar a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar a:active { background: rgba(255,255,255,0.1); }
.sidebar a.active { 
    background: rgba(255,255,255,0.1); 
    color: #fff; 
    border-left: 4px solid #6366f1;
    font-weight: 600;
}

/* 3. Main Content */
.main {
    margin-left: 260px;
    padding: 15px; 
    width: calc(100% - 260px);
}

/* 4. Card Wrapper */
.table-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    padding: 0; /* Remove padding to let table touch edges */
    margin-bottom: 20px;
    overflow-x: auto; 
}

/* 5. TABLE STYLES (The Fix) */
.table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: collapse;
    /* 'Auto' is better here because it lets us shrink the dates naturally */
    table-layout: auto; 
}

/* Headers */
.table thead th {
    background-color: #f8f9fa;
    color: #7f8c8d;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 10px 12px;
    border-bottom: 2px solid #e1e1e1;
    white-space: nowrap;
}

/* Data Cells */
.table tbody td {
    padding: 8px 12px; /* Comfortable but compact */
    vertical-align: middle;
    border-bottom: 1px solid #f1f1f1;
    font-size: 0.85rem;
    color: #2c3e50;
    white-space: nowrap; /* Prevents rows from getting tall */
}

/* --- COLUMN WIDTH CONTROLS --- */
/* Only apply to tables that are NOT in card layout mode */

/* A. The "Shrink to Fit" Trick */
/* Applied to columns that should be SMALL (ID, Date, Status, Action) */
/* Setting width to 1% forces them to be only as wide as their text */
.table:not(.responsive-table):not(.detail-card-table) th:first-child,
.table:not(.responsive-table):not(.detail-card-table) td:first-child,
.table:not(.responsive-table):not(.detail-card-table) th:nth-last-child(1),
.table:not(.responsive-table):not(.detail-card-table) td:nth-last-child(1),
.table:not(.responsive-table):not(.detail-card-table) td.col-date,
.table:not(.responsive-table):not(.detail-card-table) th.col-date,
.table:not(.responsive-table):not(.detail-card-table) td[data-label="Date"],
.table:not(.responsive-table):not(.detail-card-table) td:nth-child(4),
.table:not(.responsive-table):not(.detail-card-table) td:nth-child(5) {
    width: 1%;
    white-space: nowrap;
}

/* B. The "Space Eater" Column */
/* The Name or Description column gets 'auto' width to take up all remaining space */
.table:not(.responsive-table):not(.detail-card-table) td:nth-child(2) {
    width: auto;
    
    /* Cut off text if it gets TOO long */
    max-width: 250px; 
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 6. Visuals */
.table-hover tbody tr:hover {
    background-color: #f8f9fa;
}
.table-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    vertical-align: middle;
}
.badge {
    padding: 4px 8px;
    font-size: 0.7rem;
    border-radius: 4px;
}

/* 7. Mobile Navigation */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1000;
    background: #2c3e50;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar.mobile-open {
    transform: translateX(0);
}

/* 8. Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    /* Mobile Menu Toggle */
    .mobile-menu-toggle {
        display: block;
    }
    
    /* Sidebar - Hidden by default, slides in when toggled */
    .sidebar {
        width: 260px;
        max-width: 85vw;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1001;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    /* Sidebar links - Better touch targets on mobile */
    .sidebar a {
        padding: 16px 25px;
        min-height: 48px;
        display: flex;
        align-items: center;
        touch-action: manipulation;
    }
    
    /* Submenu items - Better spacing on mobile */
    .submenu-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Main Content - Full width on mobile, minimal side padding */
    .main {
        margin-left: 0;
        width: 100%;
        padding: 55px 6px 10px 6px;
    }
    
    /* Dashboard Headers - Stack vertically */
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Reduce large Bootstrap margin utilities on mobile */
    .mb-5 {
        margin-bottom: 1.5rem !important;
    }
    .mb-4 {
        margin-bottom: 1rem !important;
    }
    
    .d-flex.justify-content-between > div:last-child {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .d-flex.justify-content-between > div:last-child .btn {
        flex: 1 1 auto;
        min-width: calc(50% - 4px);
        font-size: 0.85rem;
        padding: 8px 12px;
    }
    
    /* =============================================
       RESPONSIVE TABLE -> CARD LAYOUT ON MOBILE
       ============================================= */
    
    /* Table card container: no horizontal scroll needed anymore */
    .table-card {
        overflow-x: visible;
        -webkit-overflow-scrolling: auto;
    }
    
    /* Reset table min-width so it fits the screen */
    .responsive-table {
        min-width: 0 !important;
        font-size: 0.85rem;
    }
    
    /* Hide the table header on mobile */
    .responsive-table thead {
        display: none;
    }
    
    /* Each row becomes a card */
    .responsive-table tbody tr {
        display: block;
        background: #fff;
        border: 1px solid #e9ecef;
        border-radius: 10px;
        margin-bottom: 10px;
        padding: 12px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
        position: relative;
    }
    
    .responsive-table tbody tr:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }
    
    /* Each cell becomes a block row inside the card */
    .responsive-table tbody td {
        display: block;
        text-align: left !important;
        padding: 4px 0 !important;
        border-bottom: none !important;
        white-space: normal !important;
        font-size: 0.85rem;
        /* Reset global column width controls that break card layout */
        width: auto !important;
        max-width: 100% !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }
    
    /* Add label before each cell content using data-label */
    .responsive-table tbody td[data-label]::before {
        content: attr(data-label) ": ";
        font-weight: 700;
        font-size: 0.7rem;
        text-transform: uppercase;
        color: #7f8c8d;
        margin-right: 6px;
    }
    
    /* Employee cell: no label prefix (it's the main card header) */
    .responsive-table tbody td[data-label="Employee"]::before {
        display: none;
    }
    
    /* Employee cell is the card header - prominent styling */
    .responsive-table tbody td[data-label="Employee"] {
        padding-bottom: 8px !important;
        margin-bottom: 6px;
        border-bottom: 1px solid #f1f1f1 !important;
    }
    
    /* Hide # column and checkbox on mobile cards */
    .responsive-table tbody td.col-num,
    .responsive-table tbody td.col-check {
        display: none !important;
    }
    
    /* Position & Status: inline on same row */
    .responsive-table tbody td.col-position,
    .responsive-table tbody td.col-status {
        display: inline-block !important;
        width: auto !important;
        margin-right: 8px;
    }
    
    /* Activity cell */
    .responsive-table tbody td[data-label="Activity"] {
        padding-top: 6px !important;
        margin-top: 2px;
    }
    
    .responsive-table tbody td[data-label="Activity"]::before {
        display: block;
        margin-bottom: 2px;
    }
    
    /* Location: inline compact */
    .responsive-table tbody td.col-location {
        padding-top: 6px !important;
    }
    
    /* Actions cell: full width, flex layout for buttons */
    .responsive-table tbody td[data-label="Actions"] {
        padding-top: 10px !important;
        margin-top: 6px;
        border-top: 1px solid #f1f1f1 !important;
    }
    
    .responsive-table tbody td[data-label="Actions"]::before {
        display: none;
    }
    
    /* Button Groups - Horizontal row inside card */
    .responsive-table .btn-group {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }
    
    .responsive-table .btn-group .btn {
        flex: 1 1 auto;
        margin-bottom: 0;
        border-radius: 6px !important;
        font-size: 0.8rem;
        padding: 6px 10px;
    }
    
    .responsive-table .btn-group form {
        flex: 0 0 auto;
    }
    
    .responsive-table .btn-group form .btn {
        width: 100%;
    }
    
    /* Emp stats row - wrap nicely */
    .responsive-table .emp-stats {
        flex-wrap: wrap;
        gap: 8px !important;
    }
    
    /* Forms - Full width inputs */
    .form-control,
    .form-select {
        width: 100% !important;
    }
    
    /* Modals - Full width on mobile */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    /* Cards - Better spacing */
    .card {
        margin-bottom: 10px;
        border-radius: 8px;
    }
    
    .card-body {
        padding: 10px;
    }
    
    /* Table card - edge to edge */
    .table-card {
        border-radius: 8px;
    }
    
    /* Filter Bar */
    .filter-bar {
        padding: 10px !important;
    }
    
    /* Dashboard Header - Employee view */
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start !important;
        padding: 15px !important;
    }
    
    .dashboard-header > div:last-child {
        width: 100%;
        margin-top: 15px;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .dashboard-header .btn {
        flex: 1 1 auto;
        min-width: calc(50% - 4px);
        font-size: 0.85rem;
    }
    
    /* Stats Bar - Wrap on mobile */
    .d-flex.gap-2,
    .d-flex.gap-3 {
        flex-wrap: wrap;
    }
    
    /* Calendar Grid - Smaller on mobile */
    .calendar-grid {
        gap: 3px;
    }
    
    .calendar-day {
        padding: 5px 0;
        font-size: 0.75rem;
    }
    
    /* Accordion - Better spacing */
    .accordion-button {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
    
    /* Nav Pills - Horizontal scroll on mobile instead of stacking */
    .nav-pills {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 6px;
        padding-bottom: 4px;
    }
    
    .nav-pills .nav-item {
        flex: 0 0 auto;
        width: auto;
        margin-bottom: 0;
    }
    
    .nav-pills .nav-item .nav-link {
        white-space: nowrap;
        font-size: 0.8rem;
        padding: 6px 12px;
    }
    
    .nav-pills .nav-item.ms-2 {
        margin-left: 0 !important;
    }
    
    /* Container adjustments */
    .container {
        padding-left: 4px;
        padding-right: 4px;
    }
    
    /* Text sizes */
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.3rem;
    }
    
    h4 {
        font-size: 1.1rem;
    }
    
    h5 {
        font-size: 1rem;
    }
    
    /* Pagination - Compact on mobile */
    .card-footer {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

/* Extra small devices (phones, less than 576px) */
@media screen and (max-width: 575px) {
    .main {
        padding: 50px 4px 10px 4px;
    }
    
    /* Card rows even more compact */
    .responsive-table tbody tr {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .responsive-table tbody td {
        font-size: 0.8rem;
    }
    
    /* Smaller buttons on very small screens */
    .responsive-table .btn-group .btn {
        font-size: 0.75rem;
        padding: 5px 8px;
    }
    
    .btn {
        font-size: 0.8rem;
        padding: 6px 10px;
    }
    
    .card-body {
        padding: 10px;
    }
    
    .modal-dialog {
        margin: 5px;
        max-width: calc(100% - 10px);
    }
    
    /* Employee name slightly smaller */
    .responsive-table tbody td[data-label="Employee"] h6 {
        font-size: 0.85rem;
    }
    
    /* Filter bar labels hidden on very small screens */
    .filter-bar label {
        display: none;
    }
}

/* Admin comment in leave requests – yellow/amber so it's clear it's from admin */
.admin-comment-badge {
    display: inline-block;
    background-color: #fff3cd;
    color: #856404;
    padding: 2px 8px;
    border-radius: 4px;
    border-left: 3px solid #ffc107;
    font-size: 0.9em;
}