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

:root {
    --primary-blue: #0d6efd;
    --primary-blue-rgb: 13, 110, 253;
    --dark-sidebar: #0f172a;
    --dark-sidebar-hover: #1e293b;
    --body-bg: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-green: #10b981;
    --warning-yellow: #f59e0b;
    --danger-red: #ef4444;
    --accent-blue: #e0f2fe;
    
    --sidebar-width: 260px;
    --header-height: 70px;
    --transition-speed: 0.3s;
}

/* Theme Options */
[data-theme="dark-blue"] {
    --body-bg: #0b0f19;
    --card-bg: #151f32;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --accent-blue: #1e293b;
}

[data-theme="emerald"] {
    --primary-blue: #10b981;
    --primary-blue-rgb: 16, 185, 129;
    --accent-blue: #d1fae5;
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Page Layout */
#wrapper {
    display: flex;
    width: 100vw;
    min-height: 100vh;
}

/* Sidebar Styling */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background-color: var(--dark-sidebar);
    color: #94a3b8;
    transition: margin-left var(--transition-speed) ease-in-out;
    display: flex;
    flex-direction: column;
    z-index: 1020;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.05);
}

#sidebar .sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    color: #ffffff;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#sidebar .sidebar-brand img {
    height: 35px;
    margin-right: 10px;
    border-radius: 6px;
}

#sidebar .sidebar-menu {
    flex-grow: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

#sidebar .menu-label {
    padding: 0.75rem 1.5rem 0.25rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    color: #475569;
}

#sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 0.7rem 1.5rem;
    color: #94a3b8;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

#sidebar .nav-link i {
    width: 20px;
    margin-right: 10px;
    font-size: 1.1rem;
    transition: transform 0.2s ease;
}

#sidebar .nav-link:hover {
    color: #ffffff;
    background-color: var(--dark-sidebar-hover);
}

#sidebar .nav-link:hover i {
    transform: scale(1.1);
}

#sidebar .nav-link.active {
    color: #ffffff;
    background-color: var(--dark-sidebar-hover);
    border-left-color: var(--primary-blue);
    font-weight: 600;
}

#sidebar .nav-link.active i {
    color: var(--primary-blue);
}

/* Submenu layout */
.submenu-collapse .nav-link {
    padding-left: 2.75rem;
    font-size: 0.9rem;
}

/* Header & Content Styling */
#content-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0; /* Prevent flex children from overflowing width */
}

#main-header {
    height: var(--header-height);
    background-color: var(--card-bg);
    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: 1010;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.sidebar-toggler {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.25rem;
}

.profile-dropdown img {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--primary-blue);
}

#main-content {
    flex-grow: 1;
    padding: 1.5rem;
}

footer {
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Premium Dashboard Cards */
.stats-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.01);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
}

.stats-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
}

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

.stats-card .card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.25rem;
    margin-bottom: 0;
}

.stats-card .card-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0;
}

/* DataTables Styling Overrides */
.table-responsive {
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
}

.table {
    margin-bottom: 0 !important;
}

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

.table td {
    padding: 0.85rem 0.75rem !important;
    vertical-align: middle;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current, 
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--primary-blue) !important;
    color: white !important;
    border-color: var(--primary-blue) !important;
}

/* Breadcrumb Styling */
.breadcrumb-item a {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 500;
}

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

/* Custom Status Badges */
.badge {
    padding: 0.45em 0.8em;
    font-weight: 600;
    border-radius: 30px;
    font-size: 0.75rem;
}

.bg-light-success {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: #047857 !important;
}

.bg-light-warning {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: #b45309 !important;
}

.bg-light-danger {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: #b91c1c !important;
}

.bg-light-info {
    background-color: rgba(13, 110, 253, 0.15) !important;
    color: #1d4ed8 !important;
}

/* Login View Styling */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    padding: 1.5rem;
}

.login-card {
    background-color: var(--card-bg);
    border: none;
    border-radius: 20px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.login-header {
    background-color: var(--dark-sidebar);
    padding: 2.5rem 2rem;
    text-align: center;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.login-header img {
    height: 48px;
    margin-bottom: 1rem;
    border-radius: 8px;
}

.login-body {
    padding: 2.5rem 2rem;
}

/* Multi-step Form Wizard Details */
.wizard-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
}

.wizard-steps > div:not(.wizard-step-line-active) {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.wizard-steps::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 4px;
    background-color: var(--border-color);
    z-index: 1;
}

.wizard-step-line-active {
    position: absolute;
    top: 20px;
    left: 0;
    height: 4px;
    background-color: var(--primary-blue);
    z-index: 2;
    transition: width 0.3s ease;
}

.wizard-step-node {
    position: relative;
    z-index: 3;
    background-color: var(--card-bg);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-muted);
    border: 3px solid var(--border-color);
    transition: all 0.3s ease;
}

.wizard-step-node.active {
    border-color: var(--primary-blue);
    color: var(--primary-blue);
    font-weight: 700;
}

.wizard-step-node.completed {
    background-color: var(--primary-blue);
    border-color: var(--primary-blue);
    color: white;
}

.wizard-step-label {
    display: block;
    margin-top: 0.5rem;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    width: max-content;
    max-width: 80px;
}

.wizard-step-node.active + .wizard-step-label,
.wizard-step-node.completed + .wizard-step-label {
    color: var(--text-primary);
}

/* Dynamic Toast Styling */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2050;
}

/* Print Styling */
@media print {
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
        font-size: 12pt;
    }
    #sidebar, #main-header, footer, .btn:not(.print-btn-original), .breadcrumb, .dataTables_length, .dataTables_filter, .dataTables_info, .dataTables_paginate {
        display: none !important;
    }
    #content-wrapper {
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
    }
    #main-content {
        padding: 0 !important;
    }
    .card {
        border: none !important;
        box-shadow: none !important;
    }
    .print-container {
        width: 100% !important;
        margin: 0 !important;
        padding: 0.5in !important;
        border: 1px solid #000000 !important;
        border-radius: 0 !important;
    }
}

/* Skeleton Loading State */
.skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: loading-skeleton 1.5s infinite;
    border-radius: 4px;
    display: inline-block;
}

@keyframes loading-skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* General CSS classes */
.rounded-xl {
    border-radius: 12px !important;
}

.rounded-2xl {
    border-radius: 16px !important;
}

.text-xs-bold {
    font-size: 0.75rem;
    font-weight: 700;
}

/* --- Desktop & Above (>= 992px) --- */
@media (min-width: 992px) {
    #sidebar.toggled,
    #wrapper.toggled-sidebar #sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
    }
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Sidebar Overlay Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1019;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* --- Tablet & Below (< 992px) --- */
@media (max-width: 991.98px) {
    .sidebar-backdrop.show {
        display: block;
        opacity: 1;
    }

    #sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        transition: margin-left 0.3s ease-in-out;
    }

    #sidebar.toggled,
    #wrapper.toggled-sidebar #sidebar {
        margin-left: 0;
    }

    #content-wrapper {
        width: 100vw;
    }

    /* Page title section stacks vertically */
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    /* Chart cards reduce height */
    .card[style*="height: 350px"] {
        height: 280px !important;
    }
    .card[style*="height: 350px"] [style*="height: 260px"] {
        height: 200px !important;
    }
}

/* --- Mobile Landscape & Below (< 768px) --- */
@media (max-width: 767.98px) {
    #main-content {
        padding: 1rem;
    }

    #main-header {
        padding: 0 1rem;
        height: 60px;
    }

    /* Page titles */
    h3.fw-bold {
        font-size: 1.25rem;
    }

    /* Stats cards — stack 1 per row on mobile */
    .stats-card {
        padding: 1.15rem;
        border-radius: 12px;
    }

    .stats-card .card-value {
        font-size: 1.4rem;
    }

    .stats-icon {
        width: 42px;
        height: 42px;
        font-size: 1.25rem;
    }

    /* Buttons in page header — full width */
    .d-flex.justify-content-between.align-items-center.mb-4 > div:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 > div:last-child .btn {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0.85rem;
        padding: 0.4rem 0.75rem;
    }

    /* Chart cards */
    .card[style*="height: 350px"] {
        height: 240px !important;
    }
    .card[style*="height: 350px"] [style*="height: 260px"] {
        height: 170px !important;
    }

    /* DataTables mobile fix */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        display: flex;
        justify-content: center;
        margin-bottom: 0.5rem;
    }

    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        display: flex;
        justify-content: center;
        margin-top: 0.5rem;
        flex-wrap: wrap;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.3rem 0.6rem !important;
        font-size: 0.8rem !important;
    }

    /* Tables — smaller text */
    .table th {
        font-size: 0.65rem !important;
        padding: 0.65rem 0.5rem !important;
        white-space: nowrap;
    }

    .table td {
        font-size: 0.8rem !important;
        padding: 0.6rem 0.5rem !important;
    }

    /* Footer stacks on mobile */
    footer .d-flex.justify-content-between {
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
        text-align: center;
    }

    footer {
        padding: 0.75rem 1rem;
        font-size: 0.75rem;
    }

    /* Wizard Steps for New Loan / Customer form */
    .wizard-step-node {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    .wizard-step-label {
        font-size: 0.6rem;
    }

    .wizard-steps {
        margin-bottom: 2.75rem;
    }

    .wizard-steps::before {
        top: 16px;
    }

    .wizard-step-line-active {
        top: 16px;
    }

    /* Form fields in 2-column that should go full on mobile */
    .row .col-6.mb-3,
    .row .col-md-6,
    .row .col-md-4,
    .row .col-md-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Login card responsive */
    .login-card {
        max-width: 100%;
        border-radius: 16px;
    }

    .login-header {
        padding: 1.75rem 1.25rem;
    }

    .login-header img {
        height: 40px;
    }

    .login-body {
        padding: 1.75rem 1.25rem;
    }

    /* Profile dropdown */
    .profile-dropdown img {
        width: 32px;
        height: 32px;
    }

    /* Modal dialogs */
    .modal-dialog {
        margin: 0.75rem;
    }

    /* Toast positioning */
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast-container .toast {
        width: 100%;
    }

    /* Badge sizing */
    .badge {
        font-size: 0.68rem;
        padding: 0.35em 0.65em;
    }

    /* Breadcrumb */
    .breadcrumb {
        font-size: 0.8rem;
    }

    /* Print receipt / Loan card responsive */
    .print-container {
        padding: 1rem !important;
    }
}

/* --- Small Mobile (< 576px) --- */
@media (max-width: 575.98px) {
    #main-content {
        padding: 0.75rem;
    }

    #main-header {
        padding: 0 0.75rem;
        height: 55px;
    }

    h3.fw-bold {
        font-size: 1.1rem;
    }

    /* Stats cards compact */
    .stats-card .card-value {
        font-size: 1.2rem;
    }

    .stats-card .card-title {
        font-size: 0.72rem;
    }

    .stats-icon {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
        border-radius: 10px;
    }

    .stats-card {
        padding: 1rem;
    }

    /* Chart cards smallest */
    .card[style*="height: 350px"] {
        height: 200px !important;
    }
    .card[style*="height: 350px"] [style*="height: 260px"] {
        height: 140px !important;
    }

    /* Sidebar brand logo */
    #sidebar .sidebar-brand img {
        height: 150px;
        width: 200px;
    }

    /* Footer text */
    footer {
        font-size: 0.7rem;
    }

    /* Card padding on small screens */
    .card.p-4 {
        padding: 1rem !important;
    }

    /* Form styling */
    .form-control, .form-select {
        font-size: 0.85rem;
        padding: 0.45rem 0.65rem;
    }

    .form-label {
        font-size: 0.8rem;
    }

    /* Buttons */
    .btn {
        font-size: 0.85rem;
    }

    .btn-sm {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    /* Wizard even smaller */
    .wizard-step-node {
        width: 28px;
        height: 28px;
        font-size: 0.72rem;
        border-width: 2px;
    }

    .wizard-step-label {
        font-size: 0.55rem;
    }

    .wizard-steps {
        margin-bottom: 2.25rem;
        padding: 0 0.5rem;
    }

    .wizard-steps::before,
    .wizard-step-line-active {
        top: 14px;
        height: 3px;
    }
}
