/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #4f46e5;
    /* Indigo 600 */
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
    --secondary-color: #64748b;
    --background-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --sidebar-width: 280px;
    --sidebar-bg: #1e1e2d;
    --sidebar-text: #9ca3af;
    --sidebar-active: #ffffff;
    --sidebar-active-bg: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

body {
    font-family: 'Inter', sans-serif !important;
    background-color: var(--background-color);
    color: var(--text-main);
    line-height: 1.6;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Sidebar Revamp */
.side-bar {
    background: var(--sidebar-bg) !important;
    width: var(--sidebar-width) !important;
    box-shadow: var(--shadow-lg);
    border-right: none;
    padding-top: 20px;
}

.side-bar .side-bar-logo {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0 25px 20px;
    margin-bottom: 20px;
}

.side-bar-manu li a {
    color: var(--sidebar-text) !important;
    font-weight: 500;
    border-radius: 8px;
    padding: 12px 15px;
    margin: 4px 15px;
    transition: all 0.3s ease;
}

.side-bar-manu li a:hover,
.side-bar-manu li a.active,
.side-bar-manu li.active>a {
    background: var(--primary-gradient) !important;
    color: var(--sidebar-active) !important;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.side-bar-manu li a .sidebar-icon img {
    filter: brightness(0) invert(0.7);
    /* Muted icon */
    transition: 0.3s;
}

.side-bar-manu li a:hover .sidebar-icon img,
.side-bar-manu li a.active .sidebar-icon img,
.side-bar-manu li.active>a .sidebar-icon img {
    filter: brightness(0) invert(1);
    /* White icon */
}

/* Header Revamp */
.main-header-section {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    /* margin-left removed: It tracks with section-container padding */
    padding: 15px 30px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.section-container {
    padding-left: var(--sidebar-width) !important;
    padding-top: 0 !important;
    transition: padding-left 0.3s ease;
}

/* Collapsed State (Desktop) */
.side-bar.active {
    width: 80px !important;
}

.side-bar.active .side-bar-logo {
    padding: 0 10px 20px;
    text-align: center;
}

.side-bar.active .side-bar-logo img {
    max-width: 40px;
}

.section-container.active {
    padding-left: 80px !important;
}

.side-bar.active .side-bar-manu li a {
    text-align: center;
    padding: 12px 0;
    margin: 4px 10px;
}

.side-bar.active .side-bar-manu li a span:not(.sidebar-icon) {
    display: none;
}

.side-bar.active .side-bar-manu li a .sidebar-icon {
    margin-right: 0;
}

/* Hide arrows in collapsed state */
.side-bar.active .side-bar-manu .dropdown::before {
    display: none;
}

/* Mobile Sidebar logic */
@media (max-width: 991px) {
    .side-bar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.2) !important;
    }

    .side-bar.active {
        transform: translateX(0);
        width: var(--sidebar-width) !important;
    }

    .side-bar.active .side-bar-manu li a span:not(.sidebar-icon) {
        display: inline;
    }

    .side-bar.active .side-bar-manu li a .sidebar-icon {
        margin-right: 10px;
    }

    .main-header-section {
        margin-left: 0;
        padding: 10px 15px;
        /* Smaller padding on mobile */
    }

    .section-container {
        padding-left: 0 !important;
    }

    .section-container.active {
        padding-left: 0 !important;
    }

    /* Mobile Dashboard Grid */
    .erp-state-overview-wrapper {
        display: grid;
        grid-template-columns: 1fr;
        /* Stack cards vertically */
        gap: 15px;
    }

    /* Touch Friendly Targets */
    .side-bar-manu li a {
        padding: 15px;
        /* Larger touch area */
        margin: 5px 10px;
    }

    .sidebar-opner {
        padding: 10px;
        /* Easier to tap burger menu */
        font-size: 24px;
    }

    /* Header adjustments */
    .header-wrapper {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .header-middle {
        display: none;
        /* Hide middle section if empty or less important */
    }

    /* Table Responsive Wrapper */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Card Padding */
    .state-overview-box {
        padding: 15px !important;
    }

    .state-overview-box h2 {
        font-size: 20px;
    }

    .state-overview-box .icons {
        width: 50px;
        height: 50px;
        line-height: 50px;
        font-size: 20px;
        min-width: 50px;
    }
}

/* Tablet Optimizations (Landscape/Large Tablets) */
@media (min-width: 768px) and (max-width: 1024px) {
    .erp-state-overview-wrapper {
        grid-template-columns: repeat(2, 1fr);
        /* 2 columns on tablet */
    }
}

/* Table Revamp */
.responsive-table {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    overflow: auto;
    /* Enable scrolling */
    max-height: 75vh;
    /* Limit height for vertical scroll */
    border: 1px solid var(--border-color);
    margin-top: 20px;
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
    white-space: nowrap;
    /* Prevent wrapping for horizontal scroll */
}

.table thead th {
    background-color: #f8fafc;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    border-top: none;
    /* Sticky Header */
    position: sticky;
    top: 0;
    z-index: 10;
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

.table tbody td {
    padding: 16px 24px;
    vertical-align: middle;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.badge {
    padding: 6px 12px;
    border-radius: 9999px;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: capitalize;
}

.bg-warning {
    background-color: #fffbeb !important;
    color: #d97706 !important;
}

.bg-primary {
    background-color: #eff6ff !important;
    color: #4f46e5 !important;
}

.bg-success {
    background-color: #ecfdf5 !important;
    color: #059669 !important;
}

.bg-danger {
    background-color: #fef2f2 !important;
    color: #dc2626 !important;
}

/* Images in table */
.table-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--shadow-sm);
}

/* Table Actions */
.table-action button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    transition: color 0.3s;
}

.table-action button:hover {
    color: var(--primary-color);
}