@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --primary: #f14724;
    --primary-light: rgba(241, 71, 36, 0.08);
    --secondary: #0f172a;
    --bg-light: #f8fafc;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --glass: rgba(255, 255, 255, 0.98);
    --glass-border: rgba(0, 0, 0, 0.04);
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --card-shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
    --input-focus-shadow: 0 0 0 4px rgba(241, 71, 36, 0.12);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --sp-1: 8px;
    --sp-2: 16px;
    --sp-3: 24px;
    --sp-4: 32px;
    --sp-5: 40px;
    --sp-6: 48px;
    --sp-8: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-size-xs: 12px;
    --font-size-sm: 13px;
    --font-size-base: 14px;
    --font-size-h3: 18px;
    --font-size-h2: 24px;
    --font-size-kpi: 22px;
    --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);

    /* System Globals */
    --radius: 16px;
    --sidebar-width: 250px;
    --font-base: 14px;
    --font-sidebar: 13px;
    --font-table: 13px;
    --font-button: 13px;
}

/* Modern Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

/* Global Color Utility Overrides */
.text-primary {
    color: var(--primary) !important;
}

.bg-primary {
    background-color: var(--primary) !important;
}

.bg-primary-light {
    background-color: var(--primary-light) !important;
}

.border-primary {
    border-color: var(--primary) !important;
}

.bg-soft-primary {
    background-color: rgba(241, 71, 36, 0.05) !important;
}

.bg-soft-success {
    background-color: rgba(16, 185, 129, 0.05) !important;
}

.bg-soft-danger {
    background-color: rgba(239, 68, 68, 0.05) !important;
}

.bg-soft-warning {
    background-color: rgba(245, 158, 11, 0.05) !important;
}

.bg-soft-info {
    background-color: rgba(59, 130, 246, 0.05) !important;
}

.fw-black {
    font-weight: 900 !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

a {
    text-decoration: none !important;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    font-size: var(--font-base);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    /* Prevent double scrollbars */
    height: 100vh;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.02em;
}

.app-wrapper {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* Premium Sidebar Rebuild */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar .brand-logo {
    padding: 24px 24px 10px 24px;
    margin-bottom: 5px;
}

.sidebar ul.nav-list {
    padding: 0 12px 20px 12px;
    list-style: none;
    overflow-y: auto;
    flex-grow: 1;
    scrollbar-width: none;
}

.sidebar ul.nav-list::-webkit-scrollbar {
    display: none;
}

.nav-label {
    padding: 32px 12px 12px 24px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4) !important;
    letter-spacing: 1.5px;
    opacity: 0.8;
}

.sidebar ul.nav-list li {
    margin-bottom: 4px;
}

.sidebar ul.nav-list li a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    font-size: var(--font-sidebar);
    font-weight: 500;
    border-radius: var(--radius);
    transition: var(--transition);
}

.sidebar ul.nav-list li a i {
    width: 20px;
    margin-right: 12px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.4);
    transition: var(--transition);
}

.sidebar ul.nav-list li a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar ul.nav-list li a:hover i {
    color: #fff;
}

.sidebar ul.nav-list li a.active {
    background: var(--primary);
    color: #fff !important;
    font-weight: 600;
    box-shadow: 0 10px 15px -3px rgba(241, 71, 36, 0.3);
}

.sidebar ul.nav-list li a.active i {
    color: #fff !important;
}

/* Main Content Structural Fix */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Changed from 100vh to ensure it fits in wrapper */
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    background: var(--bg-light);
}

.content-body {
    padding: 32px;
    padding-bottom: 100px;
    /* Fix for bottom content cutoff */
    flex-grow: 1;
    width: 100%;
}

/* Responsive Overrides */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .content-body {
        padding: 16px;
    }

    .topbar {
        padding: 12px 16px;
    }
}

/* Grid Overflow Protection */
.row {
    margin-right: -12px;
    margin-left: -12px;
}

.col,
[class*="col-"] {
    padding-right: 12px;
    padding-left: 12px;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    backdrop-filter: blur(3px);
}

.sidebar-overlay.active {
    display: block;
}

/* Hover Highlight Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease forwards;
}

.card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Premium Buttons */
.btn {
    font-weight: 700;
    border-radius: var(--radius) !important;
    padding: 10px 20px;
    font-size: var(--font-button);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0.3px;
}

.btn-primary {
    background: var(--primary) !important;
    border: none !important;
}

.btn-primary:active {
    transform: scale(0.96);
}

.btn-xs {
    padding: 6px 12px;
    font-size: 10px;
    border-radius: 6px !important;
}

/* SaaS Utility Classes */
.btn-saas {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-saas i {
    font-size: 14px;
}

.btn-saas-sm {
    padding: 6px 12px;
    font-size: 12px;
    height: 32px;
}

.btn-saas-md {
    padding: 10px 20px;
    font-size: 14px;
    height: 42px;
}

/* Standardized Form Controls */
.form-saas {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    transition: var(--transition);
    background: #fff;
    width: 100%;
}

.form-saas:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    outline: none;
}

.form-label-saas {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    display: block;
}

/* Action Bar Utilities */
.action-bar {
    background: #fff;
    padding: 12px 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 73px;
    /* Post-topbar sticky */
    z-index: 800;
    margin-left: -32px;
    margin-right: -32px;
    margin-top: -32px;
    margin-bottom: 32px;
}

/* Glass UI Elements */
.glass-panel {
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
}

/* Floating Form Labels */
.form-floating>.form-control {
    border-radius: 8px;
    border: 1px solid #eee;
}

.form-floating>.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem rgba(241, 71, 36, 0.1);
}

/* Modern Tables */
.table-modern {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-modern thead th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    white-space: nowrap;
}

.table-modern tbody td {
    padding: 10px 16px;
    color: var(--text-dark);
    font-weight: 500;
    font-size: 13px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    transition: var(--transition);
}

.table-modern tbody tr:hover {
    background-color: #f9fafb !important;
}

.table-modern tbody tr:last-child td {
    border-bottom: none;
}

/* Professional Status Badges */
.badge-status {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
}

.badge-status i {
    font-size: 8px;
}

.badge-status.success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.2);
}

.badge-status.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.2);
}

.badge-status.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.2);
}

.badge-status.primary {
    background: var(--primary-light);
    color: var(--primary);
    border-color: rgba(241, 71, 36, 0.2);
}

.badge-status.info {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.2);
}

/* Premium Form Inputs */
.form-control {
    padding: 8px 12px;
    height: 38px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-weight: 500;
    font-size: 13px;
    transition: var(--transition);
    background-color: #fff;
}

.form-control:focus {
    box-shadow: var(--input-focus-shadow);
    border-color: var(--primary);
    outline: none;
    transform: translateY(-1px);
}

.form-select {
    padding: 8px 12px;
    height: 38px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-weight: 500;
    font-size: 13px;
    transition: var(--transition);
    background-color: #fff;
}

.form-select:focus {
    box-shadow: var(--input-focus-shadow);
    border-color: var(--primary);
    outline: none;
    transform: translateY(-1px);
}

textarea.form-control {
    height: auto !important;
    min-height: 100px;
}

.card-saas {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--card-shadow);
    padding: 30px;
}

/* Flatpickr Customization */
.flatpickr-calendar {
    box-shadow: 0 10px 25px rgba(0,0,0,0.1) !important;
    border: 0 !important;
    border-radius: 12px !important;
    padding: 8px !important;
}

.flatpickr-day.selected {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
}


/* Premium Topbar Fix */
.topbar {
    background: var(--glass);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 990;
    backdrop-filter: blur(12px);
    width: 100%;
}

@media (max-width: 991.98px) {
    .topbar {
        margin: -20px -20px 20px -20px !important;
        padding: 15px 20px;
    }
}

/* Dropdown Polishing */
.dropdown-menu {
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    border-radius: 6px !important;
    padding: 6px !important;
    margin-top: 5px !important;
    animation: none !important;
}

.dropdown-item {
    border-radius: 4px;
    padding: 8px 12px;
    font-weight: 500;
    transition: none !important;
}

.dropdown-item:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

/* Ensure Flatpickr is clickable and top-level */
.flatpickr-input[readonly] {
    cursor: pointer !important;
    background-color: #fff !important;
}

.flatpickr-calendar {
    z-index: 9999 !important;
}


/* Hover lift removed for instant feel */
.hover-lift {
    transition: none !important;
}

.btn-pill {
    border-radius: 50px !important;
    padding-left: 20px !important;
    padding-right: 20px !important;
}

.vr-light {
    width: 1px;
    height: 24px;
    background: rgba(0, 0, 0, 0.1);
    margin: 0 16px;
}

.badge-pill {
    border-radius: 50px !important;
    padding: 6px 16px !important;
}

/* Specific Action Bar Button Colors */
.btn-back-pill {
    background: #94a3b8 !important;
    color: white !important;
    border: none !important;
}

.btn-back-pill:hover {
    background: #64748b !important;
}

.btn-outline-status {
    border: 1.5px solid #3b82f6 !important;
    color: #3b82f6 !important;
    background: white !important;
}

.btn-outline-status:hover {
    background: rgba(59, 130, 246, 0.05) !important;
}

.btn-cyan {
    background: #06b6d4 !important;
    color: white !important;
    border: none !important;
}

.btn-cyan:hover {
    background: #0891b2 !important;
}

.btn-orange {
    background: #f97316 !important;
    color: white !important;
    border: none !important;
}

.btn-orange:hover {
    background: #ea580c !important;
}

.currency-wrap {
    white-space: nowrap !important;
    display: inline-block;
    vertical-align: middle;
}

.badge-soft-warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

.bg-soft-warning {
    background-color: rgba(255, 193, 7, 0.1);
}

/* Skeleton Loading */
.skeleton-loader {
    background: #f1f5f9;
    background: linear-gradient(110deg, #f1f5f9 8%, #e2e8f0 18%, #f1f5f9 33%);
    border-radius: 5px;
    background-size: 200% 100%;
    animation: 1.5s shine linear infinite;
}

@keyframes shine {
    to {
        background-position-x: -200%;
    }
}

/* Dashboard Specifics */
.dashboard-card {
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.dashboard-card h2 {
    font-size: 1.5rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dashboard-card .card-body {
    padding: 1.5rem;
}

.filter-bar {
    background: #fff;
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
}

/* Skeleton Loader */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #f8f8f8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    display: inline-block;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Side Drawer Component */
.side-drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.side-drawer-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.side-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 360px;
    height: 100vh;
    background: #fff;
    z-index: 2001;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.side-drawer.active {
    transform: translateX(0);
}

.drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.drawer-footer {
    padding: 16px 24px;
    border-top: 1px solid #f1f5f9;
    background: #f8fafc;
}

/* Mobile & Tablet Overrides */
@media (max-width: 768px) {
    .side-drawer {
        width: 100%;
        border-radius: 0;
    }
}

/* Tab Overrides for Drawer */
.drawer-body .nav-pills {
    padding: 12px 24px;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    gap: 8px;
}

.drawer-body .nav-link {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    border-radius: 6px;
    padding: 8px 16px;
}

.drawer-body .nav-link.active {
    background: var(--primary) !important;
    color: #fff !important;
}

.drawer-body .table {
    margin-bottom: 0;
}

.drawer-body .table th {
    background: #f8fafc;
    border-top: 0;
    padding: 12px 24px;
    font-size: 10px;
}

.drawer-body .table td {
    padding: 16px 24px;
}

.bg-purple {
    background-color: #8b5cf6 !important;
}

.bg-soft-purple {
    background-color: #f5f3ff !important;
    color: #8b5cf6 !important;
}