:root {
    --primary: #673ab7;
    --primary-light: #ede7f6;
    --primary-dark: #5e35b1;
    --secondary: #2196f3;
    --secondary-light: #e3f2fd;
    --bg-main: #eef2f6;
    --bg-card: #ffffff;
    --text-main: #364152;
    --text-muted: #697586;
    --border-color: #e3e8ef;
    --sidebar-bg: #ffffff;
    --sidebar-text: #364152;
    --sidebar-active: #673ab7;
    --sidebar-active-bg: #ede7f6;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-lg: 16px;
}

.text-primary {
    color: var(--primary) !important;
}

.bg-primary {
    background-color: var(--primary) !important;
}

.bg-primary-light {
    background-color: var(--primary-light) !important;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
}

h1,
h2,
h3,
h4,
.brand-font {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* Sidebar Styling */
.sidebar {
    background-color: var(--sidebar-bg);
    min-height: 100vh;
    padding: 1.5rem 1rem;
    position: fixed;
    width: 260px;
    z-index: 1050;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid var(--border-color);
}

/* Mini Sidebar Logic */
@media (min-width: 992px) {
    .sidebar.collapsed {
        width: 80px;
        padding: 1.5rem 0.5rem;
    }

    .sidebar.collapsed .brand span,
    .sidebar.collapsed .nav-link span,
    .sidebar.collapsed nav .text-muted {
        opacity: 0;
        visibility: hidden;
        display: none !important;
    }

    .sidebar.collapsed .nav-link {
        justify-content: center;
        padding: 0.75rem 0;
        margin: 0 0.5rem 0.5rem;
        position: relative;
    }

    /* Custom Tooltip Styling for nav-links and brand */
    .sidebar.collapsed .nav-link::after,
    .sidebar.collapsed .brand::after {
        content: attr(data-tooltip);
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%) translateX(10px);
        background: #1e293b;
        color: white;
        padding: 6px 14px;
        border-radius: 6px;
        font-size: 0.8125rem;
        font-weight: 500;
        white-space: nowrap;
        opacity: 0;
        visibility: hidden;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: none;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
        z-index: 9999;
    }

    .sidebar.collapsed .nav-link:hover::after,
    .sidebar.collapsed .brand:hover::after {
        opacity: 1;
        visibility: visible;
        transform: translateY(-50%) translateX(20px);
    }

    /* Tooltip Arrow */
    .sidebar.collapsed .nav-link::before,
    .sidebar.collapsed .brand::before {
        content: "";
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%) translateX(10px);
        border: 6px solid transparent;
        border-right-color: #1e293b;
        opacity: 0;
        visibility: hidden;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: none;
        z-index: 9999;
    }

    .sidebar.collapsed .nav-link:hover::before,
    .sidebar.collapsed .brand:hover::before {
        opacity: 1;
        visibility: visible;
        transform: translateY(-50%) translateX(15px);
    }

    .sidebar.collapsed .brand {
        padding-left: 0;
        padding-right: 0;
        justify-content: center;
        margin-left: 0 !important;
        position: relative;
        /* Added for tooltip positioning */
    }

    .sidebar.collapsed .brand .ms-3,
    .sidebar.collapsed .brand .btn-toggle {
        display: none !important;
    }

    /* Removed hover expansion for brand to keep it stable */
    /* .sidebar.collapsed:hover .brand expansion logic removed */

    .main-content.expanded {
        margin-left: 80px;
    }
}

/* Hide sidebar on mobile by default */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }
}

.sidebar .brand {
    font-size: 1.5rem;
    color: var(--text-main);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 0.5rem;
    transition: all 0.3s;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    transition: all 0.2s;
}

.sidebar .nav-link i {
    font-size: 1.25rem;
    min-width: 24px;
    text-align: center;
}

.sidebar .nav-link span {
    transition: opacity 0.3s;
}

.sidebar .nav-link:hover {
    color: var(--primary);
    background-color: var(--sidebar-active-bg);
}

.sidebar .nav-link.active {
    color: var(--primary);
    background-color: var(--sidebar-active-bg);
}

.sidebar .nav-link.active i {
    color: var(--primary);
}

/* Main Content Area */
.main-content {
    margin-left: 260px;
    padding: 1.5rem 2rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 991.98px) {
    .main-content {
        margin-left: 0;
        padding: 1.5rem;
    }
}

/* Glassmorphism Classes */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Premium Card */
.card {
    background-color: var(--bg-card);
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 14px 0 rgb(32 40 45 / 8%);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}

/* Buttons */
.btn-primary {
    background-color: var(--primary);
    border: none;
    border-radius: 8px;
    padding: 0.625rem 1.25rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(103, 58, 183, 0.2);
}

/* Tables */
.table-responsive {
    border-radius: var(--radius);
}

.table {
    margin-bottom: 0;
    min-width: 800px;
    /* Force scroll on small screens for data integrity */
}

@media (max-width: 767.98px) {
    .table {
        min-width: 600px;
    }
}

.table thead th {
    background-color: #f8fafc;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-top: none;
}

.table td {
    vertical-align: middle;
    color: #475569;
}

/* Toggle Button Styling */
.btn-toggle {
    width: 38px;
    height: 38px;
    background-color: var(--primary-light);
    color: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    transition: all 0.2s;
    outline: none !important;
    box-shadow: none !important;
}

.btn-toggle:hover {
    background-color: var(--primary);
    color: white;
}

/* Auth Pages Centering */
.auth-wrapper {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.mobile-header {
    display: none;
    background: white;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1040;
}

@media (max-width: 991.98px) {
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1045;
}

.sidebar-overlay.show {
    display: block;
}

.br-dot-n:focus {
    border-radius: 2px !important;
}

/* Premium Badges */
.badge {
    font-weight: 500;
    padding: 0.4em 0.8em;
    border-radius: 6px;
}

.bg-primary-light {
    background-color: var(--primary-light);
    color: var(--primary);
}

.bg-info-subtle {
    background-color: #e0f2fe !important;
}

.text-info {
    color: #0369a1 !important;
}

.border-info-subtle {
    border-color: #bae6fd !important;
}

.bg-warning-subtle {
    background-color: #fef3c7 !important;
}

.text-warning {
    color: #b45309 !important;
}

.border-warning-subtle {
    border-color: #fde68a !important;
}

.bg-secondary-subtle {
    background-color: #f1f5f9 !important;
}

.text-secondary {
    color: #475569 !important;
}

.border-secondary-subtle {
    border-color: #e2e8f0 !important;
}

/* Custom Switch Styling */
.custom-switch .form-check-input {
    width: 3rem;
    height: 1.5rem;
    cursor: pointer;
}

.custom-switch .form-check-input:checked {
    background-color: #10b981;
    border-color: #10b981;
}

/* Table Enhancements */
.table-hover tbody tr {
    transition: background-color 0.2s ease;
}

.table-hover tbody tr:hover {
    background-color: #f8fafc !important;
}

.opacity-50 {
    opacity: 0.5;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}