@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --secondary-color: #0EA5E9;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --danger-color: #EF4444;
    --dark-bg: #0F172A;
    --card-bg: #FFFFFF;
    --border-color: #E2E8F0;
    --text-primary: #1E293B;
    --text-muted: #64748B;
    --sky-blue-bg: #E0F2FE;
    --sky-blue-text: #0369A1;
    --aged-red-bg: #FEE2E2;
    --aged-red-text: #991B1B;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: #F8FAFC;
    color: var(--text-primary);
    overflow-x: hidden;
}

body.sidebar-open {
    overflow: hidden;
}

.modal {
    z-index: 2000 !important;
}

.modal-backdrop {
    z-index: 1990 !important;
}

.dropdown-menu,
.popover,
.tooltip {
    z-index: 2010;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: #1E293B;
    color: #FFFFFF;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-brand i {
    color: var(--secondary-color);
}

.brand-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 50%;
    background: #FFFFFF;
}

.login-logo {
    width: 76px;
    height: 76px;
    object-fit: contain;
    border-radius: 50%;
    background: #FFFFFF;
}

.sidebar-menu {
    padding: 1rem 0;
    list-style: none;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-menu .menu-item {
    margin-bottom: 4px;
}

.sidebar-menu .menu-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: #94A3B8;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.sidebar-menu .menu-link:hover,
.sidebar-menu .menu-link.active {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.05);
    border-left-color: var(--primary-color);
}

.sidebar-menu .menu-link i {
    font-size: 1.1rem;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

.sidebar-backdrop {
    display: none;
}

/* Main Layout */
.main-wrapper {
    margin-left: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.top-navbar {
    height: 70px;
    background: #FFFFFF;
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 999;
}

.content-area {
    padding: 2rem;
    flex: 1;
    position: relative;
    isolation: isolate;
}

.dashboard-page .content-area::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: url('../images/jmf-logo.png') center / min(680px, 72vw) no-repeat;
    opacity: 0.4;
    pointer-events: none;
}

@media (max-width: 767px) {
    .dashboard-page .content-area::before {
        background-size: 150px auto;
        background-repeat: repeat-y;
        background-position: center top;
        opacity: 0.16;
    }
}

.content-area > .d-flex.justify-content-between {
    gap: 1rem;
}

/* Custom Cards */
.stat-card {
    background: #FFFFFF;
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
}

.dashboard-stat-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.dashboard-stat-link::after {
    content: '\f061';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 1rem;
    bottom: 0.65rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.dashboard-stat-link { position: relative; }

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary { background: #EEF2FF; color: var(--primary-color); }
.stat-icon.info { background: #E0F2FE; color: var(--secondary-color); }
.stat-icon.success { background: #D1FAE5; color: var(--success-color); }
.stat-icon.warning { background: #FEF3C7; color: var(--warning-color); }
.stat-icon.danger { background: #FEE2E2; color: var(--danger-color); }

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 4px 0 0 0;
}

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

/* Aged Pending Collection Status Badges */
.badge-pending-sky {
    background-color: var(--sky-blue-bg) !important;
    color: var(--sky-blue-text) !important;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #BAE6FD;
}

.badge-pending-aged-red {
    background-color: var(--aged-red-bg) !important;
    color: var(--aged-red-text) !important;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #FECACA;
    animation: pulseRed 2s infinite;
}

.badge-pending-sky,
.badge-pending-aged-red {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 4px 7px;
    font-size: 0.68rem;
    line-height: 1;
}

.btn-mark-collected {
    white-space: nowrap;
    padding: 0.28rem 0.48rem;
    font-size: 0.72rem;
}

.customer-phone-link {
    display: inline-flex;
    align-items: center;
    margin-top: 0.25rem;
    color: var(--primary-color);
    font-size: 0.8rem;
    text-decoration: none;
    white-space: nowrap;
}

.customer-phone-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.access-tabs-menu {
    max-height: 300px;
    overflow-y: auto;
    z-index: 2020;
}

.access-tab-option {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    cursor: pointer;
}

.access-tab-option:hover {
    background: #F1F5F9;
}

.pending-confirm-amount {
    padding: 1rem;
    border-radius: 12px;
    background: #ECFDF5;
    color: #047857;
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
}

#employeeCenterMap {
    height: 380px;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

@keyframes pulseRed {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.row-pending-recent {
    background-color: #F0F9FF !important;
}

.row-pending-aged {
    background-color: #FEF2F2 !important;
}

/* Glass Card */
.glass-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

/* Modern Tables */
.custom-table-card {
    background: #FFFFFF;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.custom-table th {
    background: #F1F5F9;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.custom-table td {
    padding: 1rem 1.25rem;
    vertical-align: middle;
    border-bottom: 1px solid #F1F5F9;
}

/* Custom Buttons */
.btn-primary-custom {
    background: var(--primary-color);
    color: #FFFFFF;
    border: none;
    border-radius: 10px;
    padding: 0.6rem 1.25rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-primary-custom:hover {
    background: var(--primary-hover);
    color: #FFFFFF;
    transform: translateY(-1px);
}

/* Map Picker Container */
#mapPicker, #attendanceMap {
    height: 350px;
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

/* Attendance Calendar */
.attendance-dashboard .filter-card,
.attendance-dashboard .summary-card,
.attendance-dashboard .calendar-card,
.attendance-dashboard .legend-card {
    border-radius: 18px;
    box-shadow: 0 15px 35px rgba(15, 23, 42, 0.06);
}

.attendance-filters .form-select,
.attendance-filters .form-control {
    border-radius: 12px;
}

.attendance-summary-grid {
    display: grid;
    gap: 1rem;
}

.attendance-summary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.attendance-summary-card {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    min-height: 100px;
    flex: 1 1 calc(12.5% - 1rem);
    min-width: 180px;
    max-width: 220px;
}

.attendance-summary-card.summary-pill {
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.attendance-summary-card h6 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.attendance-summary-card .summary-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.attendance-calendar-grid {
    display: grid;
    gap: 1rem;
}

.attendance-calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.attendance-calendar-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.75rem;
}

.attendance-day-cell {
    min-height: 106px;
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 16px;
    padding: 0.9rem;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.attendance-day-cell:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

.attendance-day-cell.empty {
    background: #F8FAFC;
    border-style: dashed;
    cursor: default;
}

.attendance-day-cell .day-number {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.attendance-day-cell .attendance-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.attendance-day-cell.present { background: #DCFCE7; border-color: #A7F3D0; }
.attendance-day-cell.absent { background: #FEE2E2; border-color: #FECACA; }
.attendance-day-cell.half_day { background: #FEF3C7; border-color: #FDE68A; }
.attendance-day-cell.weekly_off { background: #E0F2FE; border-color: #BAE6FD; }
.attendance-day-cell.holiday { background: #E2E8F0; border-color: #CBD5E1; }
.attendance-day-cell.leave { background: #EDE9FE; border-color: #DDD6FE; }
.attendance-day-cell.lop { background: #FAE8FF; border-color: #E879F9; }

.status-present { background: #DCFCE7; color: #166534; }
.status-absent { background: #FEE2E2; color: #B91C1C; }
.status-half_day { background: #FEF3C7; color: #92400E; }
.status-weekly_off { background: #E0F2FE; color: #0369A1; }
.status-holiday { background: #E2E8F0; color: #334155; }
.status-leave { background: #EDE9FE; color: #5B21B6; }
.status-lop { background: #F5D0FE; color: #86198F; }

.attendance-legend {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 1rem;
}

.attendance-legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 14px;
    background: #FFFFFF;
    border: 1px solid var(--border-color);
}

.legend-swatch {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    flex-shrink: 0;
}

.legend-present { background: #DCFCE7; }
.legend-absent { background: #FEE2E2; }
.legend-half_day { background: #FEF3C7; }
.legend-weekly_off { background: #E0F2FE; }
.legend-holiday { background: #E2E8F0; }
.legend-leave { background: #EDE9FE; }
.legend-lop { background: #D946EF; }

.attendance-calendar-caption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.attendance-calendar-caption .month-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.attendance-calendar-caption .calendar-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.attendance-calendar-footer {
    margin-top: 1.5rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* Employee HRMS tabs */
.hrms-tabs-card {
    padding: 0.55rem;
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.hrms-tabs-scroll {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
}

.hrms-tabs {
    width: max-content;
    min-width: 100%;
    gap: 0.4rem;
}

.hrms-tabs .nav-item {
    flex: 1 0 auto;
}

.hrms-tabs .nav-link {
    width: 100%;
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.7rem 1rem;
    border-radius: 11px;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
    transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.hrms-tabs .nav-link:hover {
    color: var(--primary-color);
    background: #EEF2FF;
}

.hrms-tabs .nav-link.active {
    color: #FFFFFF;
    background: linear-gradient(135deg, var(--primary-color), #6366F1);
    box-shadow: 0 7px 16px rgba(79, 70, 229, 0.24);
}

.hrms-tab-count {
    min-width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: #F1F5F9;
    color: var(--text-muted);
    font-size: 0.72rem;
    line-height: 1;
}

.hrms-tabs .nav-link.active .hrms-tab-count {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.2);
}

.hrms-tab-content > .tab-pane {
    outline: none;
}

.hrms-empty-state {
    height: 150px;
    text-align: center;
    color: var(--text-muted) !important;
    vertical-align: middle;
}

.hrms-empty-state i,
.hrms-empty-state span {
    display: block;
}

.hrms-empty-state i {
    margin-bottom: 0.65rem;
    color: #94A3B8;
    font-size: 1.6rem;
}

@media (max-width: 1199px) {
    .attendance-calendar-grid {
        grid-template-columns: 1fr;
    }
    .attendance-legend {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }
}

@media (max-width: 767px) {
    /* Keep an actual seven-day calendar on phones, with compact cells. */
    .attendance-calendar-header,
    .attendance-calendar-body { grid-template-columns: repeat(7, minmax(0, 1fr)); min-width: 0; gap: 0.25rem; }
    .attendance-calendar-header { font-size: 0.55rem; letter-spacing: 0; }
    .attendance-day-cell { min-height: 56px; border-radius: 8px; padding: 0.35rem 0.2rem; overflow: hidden; }
    .attendance-day-cell .day-number { font-size: 0.68rem; margin-bottom: 0.2rem; }
    .attendance-day-cell .attendance-pill { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0.16rem 0.1rem; border-radius: 4px; font-size: 0.42rem; line-height: 1.15; text-align: center; }
    .attendance-legend {
        grid-template-columns: 1fr;
    }
}

/* Responsive */
@media (max-width: 991px) {
    .sidebar {
        left: -260px;
    }
    .sidebar.show {
        left: 0;
    }
    .sidebar-backdrop.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.48);
        z-index: 998;
    }
    .main-wrapper {
        margin-left: 0;
    }
}

@media (max-width: 767px) {
    .top-navbar {
        height: 64px;
        padding: 0 1rem;
    }

    .top-navbar > div:last-child {
        gap: 0.5rem !important;
    }

    .content-area {
        padding: 1rem;
    }

    .content-area > .d-flex.justify-content-between,
    .content-area .d-flex.justify-content-between.align-items-center {
        align-items: flex-start !important;
        flex-direction: column;
    }

    .content-area > .d-flex.justify-content-between > .d-flex,
    .content-area .d-flex.justify-content-between.align-items-center > .d-flex {
        width: 100%;
        flex-wrap: wrap;
    }

    .content-area > .d-flex.justify-content-between .btn,
    .content-area .d-flex.justify-content-between.align-items-center .btn {
        flex: 1 1 auto;
    }

    .stat-card { padding: 1.1rem; }
    .stat-number { font-size: 1.45rem; }

    .custom-table th,
    .custom-table td {
        padding: 0.75rem 0.9rem;
        white-space: nowrap;
    }

    .modal-dialog { margin: 0.75rem; }
    #mapPicker, #attendanceMap { height: 280px; }

    .hrms-tabs-card {
        margin-right: -1rem;
        margin-left: -1rem;
        padding: 0.5rem 1rem;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

    .hrms-tabs {
        min-width: max-content;
    }

    .hrms-tabs .nav-item {
        flex: 0 0 auto;
    }

    .hrms-tabs .nav-link {
        width: auto;
        min-height: 42px;
        padding: 0.6rem 0.85rem;
        font-size: 0.9rem;
    }

    /* Pending collections become labelled cards instead of a clipped table. */
    .pending-responsive-table thead { display: none; }
    .pending-responsive-table,
    .pending-responsive-table tbody,
    .pending-responsive-table tr,
    .pending-responsive-table td { display: block; width: 100%; }
    .pending-responsive-table tr { margin: 0.75rem; width: auto; border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; }
    .pending-responsive-table td { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.65rem 0.8rem; white-space: normal; text-align: right; border-bottom: 1px solid #E2E8F0; font-size: 0.78rem; }
    .pending-responsive-table td:last-child { border-bottom: 0; }
    .pending-responsive-table td::before { content: ''; flex: 0 0 39%; color: var(--text-muted); font-size: 0.64rem; font-weight: 700; text-align: left; text-transform: uppercase; }
    .pending-responsive-table td:nth-child(1)::before { content: 'Customer'; }
    .pending-responsive-table td:nth-child(2)::before { content: 'Loan'; }
    .pending-responsive-table td:nth-child(3)::before { content: 'Center'; }
    .pending-responsive-table td:nth-child(4)::before { content: 'Employee'; }
    .pending-responsive-table td:nth-child(5)::before { content: 'Amount Due'; }
    .pending-responsive-table td:nth-child(6)::before { content: 'Due Date'; }
    .pending-responsive-table td:nth-child(7)::before { content: 'Age'; }
    .pending-responsive-table td:nth-child(8)::before { content: 'Status'; }
    .pending-responsive-table td:nth-child(9)::before { content: 'Action'; }
    .pending-employee-table td:nth-child(4)::before { content: 'Amount Due'; }
    .pending-employee-table td:nth-child(5)::before { content: 'Due Date'; }
    .pending-employee-table td:nth-child(6)::before { content: 'Age'; }
    .pending-employee-table td:nth-child(7)::before { content: 'Status'; }
    .pending-employee-table td:nth-child(8)::before { content: 'Action'; }
    .pending-responsive-table .customer-phone-link { display: inline-block; font-size: 0.7rem; }
    .pending-responsive-table .badge-pending-sky,
    .pending-responsive-table .badge-pending-aged-red { white-space: normal; text-align: center; justify-content: center; font-size: 0.68rem; }
}

@media (max-width: 420px) {
    .sidebar {
        width: min(85vw, 300px);
        left: -85vw;
    }

    .sidebar.show { left: 0; }
    .top-navbar .dropdown-toggle::after { display: none; }
    .attendance-summary-card { min-width: 100%; max-width: none; }
}
