/* Global Styles */
:root {
    --primary-color: #2E5A34;
    /* Dark Green - Vardhaman */
    --secondary-color: #8FCC99;
    /* Light Green */
    --accent-color: #F8F9FA;
    --text-color: #333;
    --sidebar-width: 260px;
    --header-height: 70px;
    --danger: #dc3545;
    --warning: #ffc107;
    --success: #28a745;
    --info: #17a2b8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #fff;
    /* White background as per image */
    color: var(--text-color);
    display: flex;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e0e0e0;
    z-index: 500;
}

.brand {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 10px;
}

.menu {
    flex: 1;
    padding: 10px 15px;
    overflow-y: auto;
}

/* Custom Scrollbar for sidebar */
.menu::-webkit-scrollbar {
    width: 5px;
}

.menu::-webkit-scrollbar-thumb {
    background: #e0e0e0;
    border-radius: 5px;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    color: #555;
    text-decoration: none;
    margin-bottom: 2px;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.menu-item:hover {
    background-color: #f0f7f4;
    color: var(--primary-color);
}

.menu-item.active {
    background-color: var(--primary-color);
    color: #fff;
}

.menu-item i {
    width: 20px;
    margin-right: 10px;
    font-size: 16px;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fff;
    padding: 0 40px;
    border-bottom: 1px solid #f0f0f0;
    /* Sticky */
    position: sticky;
    top: 0;
    z-index: 400;
    transition: height 0.25s ease, padding 0.25s ease, box-shadow 0.25s ease;
}

/* Compact state when page is scrolled */
.header.scrolled {
    height: 50px;
    padding: 0 30px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.header.scrolled h3 {
    font-size: 14px;
}

.header.scrolled .user-avatar {
    width: 30px;
    height: 30px;
    font-size: 12px;
}

.header.scrolled #headerClock {
    padding-right: 10px;
}

.header.scrolled #headerClockTime {
    font-size: 13px;
}

.header.scrolled #headerClockDate {
    font-size: 10px;
}

.header h3 {
    font-weight: 500;
    color: #666;
    transition: font-size 0.25s ease;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 20px;
}

.notification {
    position: relative;
    cursor: pointer;
}

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--danger);
    color: #fff;
    font-size: 10px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background-color: var(--primary-color);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

/* Page Container */
.page-container {
    padding: 40px;
    background-color: #f9fafb;
    /* Light gray for content */
    flex: 1;
}

.page-header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.btn-primary {
    background-color: #2E5A34;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.3s;
    box-shadow: 0 2px 5px rgba(46, 90, 52, 0.2);
}

.btn-primary:hover {
    background-color: #1e3d23;
}

/* Search Bar */
.search-bar-container {
    position: relative;
    margin-bottom: 30px;
}

.search-input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    background-color: #fff;
    transition: box-shadow 0.2s;
}

.search-input:focus {
    box-shadow: 0 0 0 3px rgba(46, 90, 52, 0.1);
    border-color: var(--primary-color);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
}

/* Table Card */
.table-card {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 15px 20px;
    background-color: #fcfcfc;
    border-bottom: 1px solid #eee;
    color: #666;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: #333;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #fafafa;
}

/* Role Badges */
.role-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background-color: #f0f0f0;
    color: #555;
    display: inline-block;
}

/* Status Badges */
.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

.status-active {
    background-color: #e6f9ea;
    color: #1e7e34;
}

.status-inactive {
    background-color: #ffe6e6;
    color: #bd2130;
}

/* Actions */
.action-btn {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    margin-right: 10px;
    color: #888;
    transition: color 0.2s;
}

.action-btn.view:hover {
    color: var(--info);
}

.action-btn.edit:hover {
    color: var(--primary-color);
}

.action-btn.delete:hover {
    color: var(--danger);
}

/* ========================================= */
/*       RESTORED DASHBOARD STYLES           */
/* ========================================= */

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-2px);
}

.card-title {
    font-size: 14px;
    color: #888;
    margin-bottom: 10px;
}

.card-value {
    font-size: 28px;
    font-weight: 700;
    color: #333;
}

.card-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: #f0f7f4;
    color: var(--primary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.card-trend {
    font-size: 12px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.trend-up {
    color: var(--success);
}

.trend-down {
    color: var(--danger);
}

.trend-text {
    color: #888;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.chart-container {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    position: relative;
    /* IMPORTANT for Chart.js responsiveness */
    height: 400px;
    width: 100%;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #333;
}

/* Table Section */
.table-section {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    margin-top: 30px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Responsive */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }
}

/* ========================================= */
/*              MODAL STYLES                 */
/* ========================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-container {
    background: #fff;
    width: 850px;
    max-width: 95%;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-container {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fcfcfc;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    max-height: 70vh;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid #eee;
    background: #fcfcfc;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
}

.btn-secondary {
    background: #e9ecef;
    color: #495057;
}

.btn-secondary:hover {
    background: #dee2e6;
}

/* Form Styles for Modal */
.form-group-modal {
    margin-bottom: 15px;
}

.form-label-modal {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.form-input-modal {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.form-input-modal:focus {
    border-color: var(--primary-color);
}

.detail-row {
    display: flex;
    margin-bottom: 12px;
    border-bottom: 1px solid #f5f5f5;
    padding-bottom: 12px;
}

.detail-label {
    width: 140px;
    font-weight: 600;
    color: #555;
    font-size: 13px;
}

.detail-value {
    color: #333;
    font-size: 13px;
}

/* Search Suggestions */
.search-bar-container {
    position: relative;
    /* Anchor for absolute suggestions */
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.search-suggestions.active {
    display: block;
}

.suggestion-item {
    padding: 10px 15px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    border-bottom: 1px solid #f9f9f9;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background-color: #f0f7f4;
    /* Light green hover matching theme */
    color: var(--primary-color);
}

.suggestion-highlight {
    font-weight: 600;
    color: var(--primary-color);
}

/* ========================================= */
/*           CUSTOMER MASTER STYLES          */
/* ========================================= */

.page-container-full {
    height: calc(100vh - var(--header-height));
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 40px;
    background-color: #f9fafb;
}

.table-card-full {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-top: 20px;
}

.table-container-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* Sticky Header specific to scroll container */
.table-container-scroll th {
    position: sticky;
    top: 0;
    z-index: 10;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.search-wrapper {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Specific Toolbar Elements */
.search-select {
    width: 150px;
    padding-left: 15px;
    height: 42px;
    /* Match inputs */
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    outline: none;
}

.search-box-wrapper {
    margin-bottom: 0;
    width: 300px;
}

.btn-refresh {
    font-size: 18px;
    color: var(--primary-color);
    background: none;
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-refresh:hover {
    transform: rotate(180deg);
}

.col-actions {
    text-align: center !important;
    white-space: nowrap;
}
/* Override DataTables inline specificity for action cells */
table.dataTable td.col-actions,
table.dataTable th.col-actions {
    text-align: center !important;
    white-space: nowrap;
}

/* Modal Form Specifics */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.full-width {
    grid-column: span 2;
}

.section-divider {
    margin-top: 15px;
    border-bottom: none;
}

.section-divider .detail-label {
    width: 100%;
    color: var(--primary-color);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-save {
    background: var(--primary-color);
    color: white;
}

.btn-save:hover {
    background: #1e3d23;
}

/* View Mode / Disabled Input Styling */
.form-input-modal:disabled {
    background-color: #f8f9fa;
    border: 1px dashed #ced4da;
    /* Dashed border to indicate read-only */
    color: #333;
    /* Keep text dark for readability */
    cursor: default;
}

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

/* User Profile Dropdown */
.user-info {
    position: relative;
    cursor: pointer;
}

.user-info::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 0;
    width: 100%;
    height: 15px;
    background: transparent;
}


.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    min-width: 150px;
    z-index: 1000;
    overflow: hidden;
    margin-top: 10px;
    border: 1px solid #eee;
}

.user-info:hover .dropdown-menu,
.user-profile:hover .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 10px 15px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s;
}

.dropdown-menu a:hover {
    background-color: #f8f9fa;
    color: var(--primary-color);
}

.dropdown-menu i {
    margin-right: 8px;
    color: #777;
}

.dropdown-menu a:hover i {
    color: var(--primary-color);
}
/* ========================================= */
/*         DATATABLE CONTROLS STYLES         */
/* ========================================= */

/* Top controls bar (length selector + export) — above table scroll area */
.dt-controls-top {
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
}
.dt-controls-top .dataTables_length { float: none; }
.dt-controls-top .dt-buttons { float: none; margin-bottom: 0; }

/* Non-scroll pages: float export button to the right */
.dataTables_wrapper > .dt-buttons {
    float: right;
    clear: none;
    margin-bottom: 6px;
}
/* Ensure table starts on a new line after floated elements */
.dataTables_wrapper > table.dataTable {
    clear: both;
}

/* Bottom controls bar (info + pagination) — below table scroll area */
.dt-controls-bottom {
    padding: 8px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid #f0f0f0;
}
.dt-controls-bottom .dataTables_info { float: none; margin: 0; }
.dt-controls-bottom .dataTables_paginate { float: none; margin: 0; }

/* Export / Buttons */
.dt-button, .dt-button:visited {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    color: #475569 !important;
    padding: 7px 14px !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    margin-right: 6px !important;
    box-shadow: none !important;
    transition: all 0.2s !important;
}
.dt-button:hover {
    background: #e2e8f0 !important;
    color: #1e293b !important;
}
.dt-button-collection {
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
    padding: 6px !important;
    background: #fff !important;
}
.dt-button-collection .dt-button {
    display: block !important;
    width: 100% !important;
    margin: 2px 0 !important;
    text-align: left !important;
}

/* Length selector (rows per page) */
.dataTables_wrapper .dataTables_length {
    padding: 10px 0 12px 0;
    color: #475569;
    font-size: 13px;
}
.dataTables_wrapper .dataTables_length select {
    padding: 5px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    color: #1e293b;
    background: #fff;
    cursor: pointer;
    margin: 0 4px;
    outline: none;
}
.dataTables_wrapper .dataTables_length select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(46,90,52,0.1);
}

/* Row-count info */
.dataTables_wrapper .dataTables_info {
    padding: 10px 0;
    color: #94a3b8;
    font-size: 12px;
}

/* Pagination */
.dataTables_wrapper .dataTables_paginate {
    padding: 8px 0;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    display: inline-block;
    padding: 5px 11px !important;
    margin: 0 2px !important;
    border-radius: 6px !important;
    border: 1px solid #e2e8f0 !important;
    font-size: 13px !important;
    color: #475569 !important;
    cursor: pointer !important;
    background: #f8fafc !important;
    transition: all 0.2s !important;
    box-shadow: none !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #e2e8f0 !important;
    color: #1e293b !important;
    border-color: #cbd5e1 !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--primary-color) !important;
    color: #fff !important;
    border-color: var(--primary-color) !important;
    font-weight: 600 !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    opacity: 0.4 !important;
    cursor: default !important;
    background: #f8fafc !important;
    color: #94a3b8 !important;
}

/* Sticky pagination bar inside scrollable table containers */
.table-container-scroll .dataTables_wrapper .dt-controls-bottom {
    position: sticky;
    bottom: 0;
    z-index: 5;
}

/* Header Clock */
#headerClock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 2px 14px 2px 0;
    border-right: 1px solid #f0f0f0;
    margin-right: 4px;
}
#headerClockTime {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
    line-height: 1.3;
}
#headerClockDate {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
}
