/* 
 * App Vibrant Premium - High Energy & Modern Enterprise
 * Inspired by Mercury/Revolut FinTech Design Systems
 */

:root {
    /* Brand Colors - High Vibrancy */
    --primary: #fdb913;
    --primary-alt: #ff8c00; /* Deep Orange */
    --primary-soft: rgba(253, 185, 19, 0.12);
    --primary-gradient: linear-gradient(135deg, #fdb913 0%, #ffa800 100%);
    --secondary: #0f172a;

    /* Neutral Warm Palette */
    --bg-main: #fdfcf6; /* Warm Off-White */
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-soft: #f1f5f9;

    /* Text Palette */
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* Semantic High-Impact Colors */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;

    /* Radii & Floating Shadows */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-floating:
        0 10px 40px -10px rgba(0, 0, 0, 0.08),
        0 4px 6px -2px rgba(0, 0, 0, 0.03);
    --shadow-active: 0 0 0 4px var(--primary-soft);
}

body {
    font-family:
        "Outfit",
        "Inter",
        system-ui,
        -apple-system,
        sans-serif; /* Preferred Outfit for more character */
    background: var(--bg-main) !important;
    color: var(--text-main);
    font-size: 0.95rem;
    line-height: 1.6;
    overflow-x: hidden !important; /* Prevent global horizontal scroll */
}

/* Sidebar - Premium Glassmorphism Redesign */
.main-sidebar {
    background: rgba(255, 255, 255, 0.9) !important; /* Slightly more opaque for better readability */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(0, 0, 0, 0.05) !important;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.02) !important;
    height: 100vh !important;
    z-index: 1038;
    overflow-x: hidden !important; /* Ensure main container doesn't scroll sideways */
}

/* Ensure the sidebar content is scrollable and not cut off */
.main-sidebar .sidebar {
    height: calc(100vh - 75px) !important; /* Account for brand logo height */
    overflow-y: auto !important;
    overflow-x: hidden !important; /* STRICT: No horizontal scroll */
    padding-bottom: 3rem !important;
    width: 250px !important; /* Force width to match container */
}

/* Custom Scrollbar for Sidebar */
.main-sidebar .sidebar::-webkit-scrollbar {
    width: 4px;
}
.main-sidebar .sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.main-sidebar .sidebar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.brand-link {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
    padding: 1.2rem 1rem !important;
    background: transparent !important;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 75px;
}

.nav-sidebar {
    padding-top: 15px;
}

.nav-sidebar .nav-item {
    margin-bottom: 2px;
}

.nav-sidebar .nav-link {
    border-radius: 12px;
    margin: 4px 12px;
    padding: 10px 16px;
    color: #475569 !important;
    font-weight: 500;
    font-size: 0.92rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
}

.nav-sidebar .nav-link:hover {
    background: rgba(253, 185, 19, 0.1) !important;
    color: var(--primary-alt) !important;
    /* Removed transform: translateX to prevent overflow triggers */
}

.nav-sidebar .nav-link i:first-child {
    font-size: 1.1rem;
    width: 28px;
    text-align: center;
    margin-right: 12px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-sidebar .nav-link:hover i:first-child {
    transform: scale(1.2);
}

/* Active State indicator */
.nav-sidebar .nav-link.active {
    background: var(--primary-gradient) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(253, 185, 19, 0.3) !important;
    font-weight: 600;
}

.nav-sidebar .nav-link.active i:first-child {
    color: #ffffff !important;
}

/* Nested Menus (Treeview) Refinement */
.nav-treeview {
    padding-left: 10px; /* Reduced to save horizontal space */
    margin-bottom: 10px;
    overflow-x: hidden !important;
}

.nav-treeview .nav-link {
    margin: 2px 8px 2px 5px !important; /* Tighter margins */
    padding: 8px 12px;
    font-size: 0.85rem;
    background: transparent !important;
    color: #64748b !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-treeview .nav-link i {
    font-size: 0.6rem !important;
    width: 20px !important;
}

.nav-treeview .nav-link:hover {
    color: var(--primary-alt) !important;
    background: rgba(253, 185, 19, 0.05) !important;
}

.nav-treeview .nav-link.active {
    background: rgba(253, 185, 19, 0.1) !important;
    color: var(--primary-alt) !important;
    box-shadow: none !important;
}

/* Custom indicator for parents of active children */
.nav-item.menu-open > .nav-link {
    color: var(--primary-alt) !important;
    font-weight: 600;
}

/* Navbar - Clean Glass */
.main-header {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.navbar-search-modern {
    background: var(--border-soft);
    border: 1.5px solid transparent;
    border-radius: 99px;
    padding: 6px 16px;
}

.navbar-search-modern:focus-within {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: var(--shadow-active);
}

/* Content Wrapper */
.content-wrapper {
    background: var(--bg-main) !important;
    padding-bottom: 3rem;
}

.content-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--secondary);
    letter-spacing: -0.02em;
}

/* Dashboard Floating Stat Cards */
.small-box {
    background: var(--surface) !important;
    border: none !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-floating) !important;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-bottom: 1.5rem;
}

.small-box:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 50px -15px rgba(0, 0, 0, 0.12) !important;
}

.small-box .inner {
    padding: 2rem 1.5rem !important;
}

.small-box .inner p {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
}

.small-box .inner h3 {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--secondary);
}

.small-box .icon {
    display: block !important;
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 2.5rem;
    opacity: 0.15;
    color: var(--primary-alt);
    transition: all 0.3s;
}

.small-box:hover .icon {
    transform: scale(1.1) rotate(-8deg);
    opacity: 0.25;
}

.small-box-footer {
    background: var(--primary-soft) !important;
    color: var(--primary-alt) !important;
    font-weight: 700;
    padding: 10px !important;
    text-align: center !important;
    transition: all 0.2s;
}

/* Table Design - High Contrast Clean */
.card {
    background: var(--surface) !important;
    border: none !important; /* No border for 'floating' card look */
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-floating) !important;
    overflow: hidden;
}

.card-header {
    border-bottom: 1px solid var(--border-soft) !important;
    padding: 1.25rem 1.75rem !important;
}

.card-title {
    font-weight: 700;
    font-size: 1rem;
}

.cmg-main-table thead th {
    background: #f8fafc !important;
    color: var(--text-muted) !important;
    font-weight: 700 !important;
    padding: 16px 1.75rem !important;
}

.cmg-main-table tbody tr:hover {
    background: #fffaf0 !important; /* Warm brand hover */
}

.cmg-main-table td {
    padding: 1.25rem 1.75rem !important;
    border-bottom: 1px solid var(--border-soft) !important;
}

/* Badges - Solid High Vibrancy */
.badge {
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-success {
    background: #e6fffa !important;
    color: #047857 !important;
    border: 1px solid #b2f5ea !important;
}
.badge-danger {
    background: #fff5f5 !important;
    color: #c53030 !important;
    border: 1px solid #feb2b2 !important;
}
.badge-warning {
    background: #fffff0 !important;
    color: #b7791f !important;
    border: 1px solid #faf089 !important;
}
.badge-primary {
    background: #ebf8ff !important;
    color: #2b6cb0 !important;
    border: 1px solid #bee3f8 !important;
}

/* Refined High-Contrast Badges (Pop version) */
.badge-pop {
    color: #fff !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

/* Buttons - Jewel Tone Gradients */
.btn {
    border: none !important;
    border-radius: var(--radius-sm);
    font-weight: 700;
    padding: 10px 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-gradient) !important;
    color: #ffffff !important;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(253, 185, 19, 0.3);
}

.btn-info {
    background: #f8fafc !important;
    color: #475569 !important;
    border: 1px solid var(--border) !important;
}
.btn-info:hover {
    background: var(--border-soft) !important;
}

.btn-danger {
    background: #fff5f5 !important;
    color: var(--danger) !important;
    border: 1px solid #feb2b2 !important;
}
.btn-danger:hover {
    background: #fed7d7 !important;
}

/* Input Group Alignment Fix */
.input-group-append .btn, .input-group-prepend .btn {
    height: 100%;
    margin: 0 !important;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none !important;
    border-left: 1px solid var(--border) !important;
    background: #f8fafc !important;
}

.input-group-sm .btn {
    padding: 0 12px !important;
    font-size: 0.8rem !important;
}

.form-control {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    padding: 0.6rem 1rem;
    height: auto;
    transition: all 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: var(--shadow-active);
}

.input-group-sm > .form-control {
    border-radius: var(--radius-md) 0 0 var(--radius-md) !important;
    padding: 0.5rem 1rem;
}

/* Breadcrumb Styling */
.breadcrumb {
    background: transparent !important;
    padding: 0 !important;
}

.breadcrumb-item a {
    color: var(--primary-alt);
    font-weight: 600;
}
.breadcrumb-item.active {
    font-weight: 700;
    color: var(--secondary);
}

/* Global Crystal Loader */
#global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    flex-direction: column;
    gap: 20px;
}

.crystal-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(253, 185, 19, 0.1);
    border-top: 5px solid var(--primary);
    border-radius: 50%;
    animation: crystalSpin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    box-shadow: 0 0 30px rgba(253, 185, 19, 0.2);
}

.loader-text {
    font-family: "Outfit";
    font-weight: 800;
    color: var(--secondary);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 0.85rem;
    animation: loaderPulse 1.5s ease-in-out infinite;
}

@keyframes crystalSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes loaderPulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.95);
    }
}
