/* CSS Custom Variables for Premium Teal Theme */
:root {
    --teal-primary: #00a3c4;
    --teal-hover: #0087a3;
    --teal-dark: #0f4c5c;
    --teal-darker: #092e38;
    --teal-light: #e0f2f6;
    --bg-light: #f4f7f6;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #334155;
    --text-muted: #64748b;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
}

/* Base Styles */
body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--teal-dark);
}

/* App Layout Structure */
#wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    min-height: 100vh;
}

#sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--teal-darker) 0%, var(--teal-dark) 100%);
    color: rgba(255, 255, 255, 0.85);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.05);
}

#sidebar.active {
    margin-left: calc(-1 * var(--sidebar-width));
}

#content {
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    background-color: var(--bg-light);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

/* Sidebar Styling details */
.sidebar-header {
    padding: 24px 20px;
    background-color: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header a {
    color: #ffffff;
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-menu {
    padding: 20px 0;
    list-style: none;
    margin: 0;
}

.sidebar-menu-title {
    padding: 0 24px 8px 24px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255, 255, 255, 0.4);
}

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

.sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.sidebar-menu-link:hover, 
.sidebar-menu-link.active {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-menu-link.active {
    border-left-color: var(--teal-primary);
    background-color: rgba(0, 163, 196, 0.15);
}

.sidebar-menu-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    transition: color 0.2s ease;
}

.sidebar-menu-link:hover i,
.sidebar-menu-link.active i {
    color: var(--teal-primary);
}

/* Accordion Submenu Custom Styling */
.submenu-toggle {
    cursor: pointer;
    justify-content: space-between;
}

.submenu-toggle::after {
    display: inline-block;
    margin-left: .255em;
    vertical-align: .255em;
    content: "";
    border-top: .3em solid;
    border-right: .3em solid transparent;
    border-bottom: 0;
    border-left: .3em solid transparent;
    transition: transform 0.2s ease;
}

.submenu-toggle.expanded::after {
    transform: rotate(180deg);
}

.sidebar-submenu {
    list-style: none;
    padding-left: 0;
    background-color: rgba(0, 0, 0, 0.1);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.sidebar-submenu.show {
    max-height: 200px;
}

.sidebar-submenu .sidebar-menu-link {
    padding-left: 48px;
    font-size: 0.88rem;
}

/* Top Navbar Style */
.top-navbar {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 15px 25px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.01);
}

.navbar-toggle-btn {
    background: transparent;
    border: none;
    color: var(--teal-dark);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.navbar-toggle-btn:hover {
    background-color: #f1f5f9;
}

/* Premium Card Design */
.custom-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
    margin-bottom: 24px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.custom-card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-card-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--teal-dark);
}

.custom-card-body {
    padding: 24px;
}

/* KPI Card Style */
.kpi-card {
    border-left: 4px solid var(--teal-primary) !important;
}
.kpi-card.kpi-unpaid {
    border-left-color: #ef4444 !important;
}
.kpi-card.kpi-total {
    border-left-color: var(--teal-dark) !important;
}
.kpi-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}
.kpi-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.2;
}
.kpi-icon {
    font-size: 2.2rem;
    opacity: 0.15;
    color: var(--teal-dark);
}
.kpi-card.kpi-unpaid .kpi-icon {
    color: #ef4444;
}

/* Form Styles */
.form-label {
    font-weight: 600;
    color: var(--teal-dark);
    font-size: 0.88rem;
    margin-bottom: 6px;
}

.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.92rem;
    transition: all 0.2s ease-in-out;
}

.form-control:focus, .form-select:focus {
    border-color: var(--teal-primary);
    box-shadow: 0 0 0 4px rgba(0, 163, 196, 0.1);
    color: #1e293b;
}

/* Custom Styled Buttons */
.btn {
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 0.92rem;
    transition: all 0.2s;
}

.btn-teal {
    background-color: var(--teal-primary);
    color: #ffffff;
    border: none;
}

.btn-teal:hover {
    background-color: var(--teal-hover);
    color: #ffffff;
}

.btn-teal-dark {
    background-color: var(--teal-dark);
    color: #ffffff;
    border: none;
}

.btn-teal-dark:hover {
    background-color: var(--teal-darker);
    color: #ffffff;
}

/* Table styling with Premium Teal touch */
.table-responsive {
    border-radius: 12px;
    overflow-x: auto !important; /* Enable horizontal scrolling when table is wider than card */
}

.custom-table {
    width: 100% !important;
    border-collapse: collapse;
}

.custom-table thead th {
    background-color: var(--teal-dark);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 10px 8px;
    border: none;
    white-space: nowrap;
}

.custom-table tbody td {
    padding: 10px 8px;
    font-size: 0.85rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    white-space: nowrap; /* Prevent ugly text wrapping in data columns */
}

.custom-table tbody tr:hover {
    background-color: rgba(0, 163, 196, 0.02);
}

.custom-table tfoot th,
.custom-table tfoot td {
    padding: 10px 8px;
    font-size: 0.85rem;
    color: var(--text-main);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    white-space: nowrap;
}
.custom-table tfoot tr.table-light-total {
    background-color: var(--teal-light);
}
.text-teal-dark {
    color: var(--teal-dark) !important;
}
.total-highlight-cell {
    background-color: #000000 !important; /* Solid Black Background */
    color: #facc15 !important; /* Premium Bright Yellow/Gold Text */
    font-weight: 700 !important;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
    box-shadow: inset 0 0 2px rgba(255,255,255,0.1);
}

/* Status Badges */
.status-badge {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 50px;
    display: inline-block;
}

.status-paid {
    background-color: #d1fae5;
    color: #065f46;
}

.status-unpaid {
    background-color: #fee2e2;
    color: #991b1b;
}

/* DataTables elements customization */
.dataTables_wrapper .dataTables_paginate .paginate_button.current, 
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--teal-primary) !important;
    border-color: var(--teal-primary) !important;
    color: #ffffff !important;
    border-radius: 6px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--teal-light) !important;
    border-color: var(--teal-light) !important;
    color: var(--teal-dark) !important;
    border-radius: 6px;
}

.dataTables_filter input {
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    padding: 6px 12px !important;
    margin-left: 8px !important;
    outline: none;
}

.dataTables_filter input:focus {
    border-color: var(--teal-primary) !important;
    box-shadow: 0 0 0 3px rgba(0, 163, 196, 0.1) !important;
}

/* DataTables Buttons customization */
.dt-buttons {
    margin-bottom: 15px;
}

.dt-button {
    background-color: #ffffff !important;
    border: 1px solid var(--border-color) !important;
    color: var(--teal-dark) !important;
    border-radius: 6px !important;
    padding: 6px 14px !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    transition: all 0.2s !important;
    margin-right: 6px !important;
    box-shadow: none !important;
    background-image: none !important;
}

.dt-button:hover {
    background-color: var(--teal-light) !important;
    border-color: var(--teal-primary) !important;
    color: var(--teal-dark) !important;
}

/* Floating/Hidden inputs for custom date ranges */
.custom-date-inputs {
    display: none;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--border-color);
}

.custom-date-inputs.active {
    display: flex;
}

/* Print Invoice Styling */
.invoice-container {
    background: #ffffff;
    max-width: 850px;
    margin: 30px auto;
    padding: 50px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.02);
    border: 1px solid var(--border-color);
}

.invoice-header-logo {
    font-size: 24px;
    font-weight: 800;
    color: var(--teal-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.invoice-details-table {
    width: 100%;
    margin-top: 30px;
}

.invoice-details-table th {
    background-color: #f8fafc;
    border-bottom: 2px solid var(--border-color);
    padding: 12px;
    font-weight: 700;
    color: var(--teal-dark);
}

.invoice-details-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

/* Mobile responsive sidebar rules */
@media(max-width: 992px) {
    #sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
    }
    #sidebar.active {
        margin-left: 0;
    }
}

/* Print Media Query */
@media print {
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
        font-size: 12px !important;
    }
    
    #sidebar, 
    .top-navbar, 
    .btn, 
    .card-header, 
    .no-print,
    .dataTables_length,
    .dataTables_filter,
    .dataTables_info,
    .dataTables_paginate,
    .dt-buttons {
        display: none !important;
    }
    
    #content {
        margin-left: 0 !important;
        padding: 0 !important;
        min-height: auto !important;
    }
    
    .invoice-container {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    .invoice-details-table th {
        background-color: #f1f5f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
