@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Modern Color Palette - Inspired by modern ERP dashboards */
    --primary-color: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    /* Indigo 600 */
    --primary-light: #e0e7ff;
    /* Indigo 100 */
    --secondary-color: #64748b;
    /* Slate 500 */
    --accent-color: #8b5cf6;
    /* Violet 500 */
    --success-color: #10b981;
    /* Emerald 500 */
    --warning-color: #f59e0b;
    /* Amber 500 */
    --danger-color: #ef4444;
    /* Red 500 */
    --info-color: #06b6d4;
    /* Cyan 500 */

    /* Modern Background Gradients */
    --bg-gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --bg-gradient-success: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --bg-gradient-warning: linear-gradient(135deg, #fa709a 0%, #fee140 100%);

    /* Dynamic Sidebar Colors */
    --sidebar-gradient-start: #667eea;
    --sidebar-gradient-end: #764ba2;
    --sidebar-gradient: linear-gradient(135deg, var(--sidebar-gradient-start) 0%, var(--sidebar-gradient-end) 100%);

    /* Theme Backgrounds - Light Mode */
    --bg-body: #fafbfc;
    /* Very light gray */
    --bg-surface: #ffffff;
    --bg-sidebar: #1e293b;
    /* Dark slate */
    --bg-sidebar-hover: #334155;
    /* Lighter slate */
    --bg-header: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;

    /* Dark Theme Variables */
    --bg-body-dark: #0f172a;
    /* Very dark slate */
    --bg-surface-dark: #1e293b;
    /* Dark slate */
    --bg-sidebar-dark: #0f172a;
    /* Very dark */
    --bg-sidebar-hover-dark: #1e293b;
    /* Dark slate */
    --bg-header-dark: #1e293b;
    /* Dark slate */
    --bg-card-dark: #334155;
    /* Medium dark slate */
    --bg-card-hover-dark: #475569;
    /* Lighter dark slate */

    /* Text Colors */
    --text-main: #1e293b;
    /* Slate 800 */
    --text-muted: #64748b;
    /* Slate 500 */
    --text-light: #f1f5f9;
    /* Slate 100 */
    --text-white: #ffffff;

    /* Dark Text Colors */
    --text-main-dark: #f1f5f9;
    /* Slate 100 */
    --text-muted-dark: #94a3b8;
    /* Slate 400 */
    --text-light-dark: #475569;
    /* Slate 600 */

    /* Modern Spacing & Borders */
    --sidebar-width: 280px;
    --border-radius: 1rem;
    /* 16px - more modern */
    --border-radius-sm: 0.5rem;
    /* 8px */
    --border-radius-lg: 1.5rem;
    /* 24px */
    --border-color: #e2e8f0;
    /* Slate 200 */
    --border-color-dark: #334155;
    /* Slate 700 */

    /* Modern Shadows */
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --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);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Animations */
    --transition-fast: all 0.15s ease;
    --transition-normal: all 0.3s ease;
    --transition-slow: all 0.5s ease;
}

/* Dark Theme Support */
[data-theme="dark"] {
    --bg-body: var(--bg-body-dark);
    --bg-surface: var(--bg-surface-dark);
    --bg-sidebar: var(--bg-sidebar-dark);
    --bg-sidebar-hover: var(--bg-sidebar-hover-dark);
    --bg-header: var(--bg-header-dark);
    --bg-card: var(--bg-card-dark);
    --bg-card-hover: var(--bg-card-hover-dark);
    --text-main: var(--text-main-dark);
    --text-muted: var(--text-muted-dark);
    --text-light: var(--text-light-dark);
    --border-color: var(--border-color-dark);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    overflow-x: auto;
    line-height: 1.6;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Modern Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Color Picker Styles */
.color-option {
    position: relative;
    transition: var(--transition-fast);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-option:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.color-option.active {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.5);
}

.dropdown-menu {
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

/* Layout Wrapper */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Modern Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-gradient);
    color: var(--text-light);
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition-normal);
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
}

.sidebar-header {
    height: 72px;
    display: flex;
    align-items: center;
    padding: 0 2rem;
    position: relative;
    z-index: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    font-size: 1.375rem;
    font-weight: 800;
    color: white;
    text-decoration: none;
    letter-spacing: -0.025em;
    transition: var(--transition-fast);
    background: linear-gradient(135deg, #ffffff 0%, rgba(255, 255, 255, 0.8) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-brand:hover {
    transform: translateY(-1px);
}

.sidebar-nav {
    padding: 2rem 0 1rem;
    position: relative;
    z-index: 1;
}

.nav-item {
    position: relative;
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 1rem 2rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition-fast);
    text-decoration: none;
    border-radius: 0 2rem 2rem 0;
    margin: 0 0.5rem 0 0;
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
    transition: var(--transition-fast);
    border-radius: 0 2rem 2rem 0;
}

.nav-link:hover::before,
.nav-link.active::before {
    width: 100%;
}

.nav-link:hover,
.nav-link.active {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.nav-link i {
    width: 20px;
    margin-right: 1rem;
    font-size: 1.1rem;
    text-align: center;
    transition: var(--transition-fast);
}

.nav-link:hover i,
.nav-link.active i {
    transform: scale(1.1);
}

.nav-link[data-bs-toggle="collapse"]::after {
    display: inline-block;
    margin-left: auto;
    vertical-align: 0.255em;
    content: "";
    border-top: 0.3em solid;
    border-right: 0.3em solid transparent;
    border-bottom: 0;
    border-left: 0.3em solid transparent;
    opacity: 0.5;
    transition: transform 0.2s;
}

.nav-link[aria-expanded="true"]::after {
    transform: rotate(-180deg);
}

.submenu .nav-link {
    padding-left: 3.5rem;
    font-size: 0.9rem;
    margin-left: 1rem;
}

.submenu .nav-link:hover {
    transform: translateX(8px);
}

/* Main Content Area */
.main-wrapper {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Modern Topbar */
.topbar {
    height: 72px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    position: sticky;
    top: 0;
    z-index: 99;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .topbar {
    background: rgba(30, 41, 59, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.page-content {
    padding: 2.5rem;
    flex-grow: 1;
    background: var(--bg-body);
}

/* Modern Cards */
.card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    transition: var(--transition-normal);
    overflow: visible;
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--bg-gradient-primary);
    opacity: 0;
    transition: var(--transition-normal);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.card:hover::before {
    opacity: 1;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--text-main);
    margin: 0;
}

.card-body {
    padding: 2rem;
}

/* Modern Stats Cards */
.stat-card {
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
    border-radius: 50%;
    transform: translate(30px, -30px);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    position: relative;
    z-index: 1;
    transition: var(--transition-normal);
}

.stat-icon.primary {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.stat-icon.success {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: var(--success-color);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.stat-icon.warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: var(--warning-color);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.stat-icon.danger {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: var(--danger-color);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.stat-icon:hover {
    transform: scale(1.1);
}

.stat-content h3 {
    font-size: 2rem;
    font-weight: 800;
    margin: 0;
    line-height: 1.2;
    color: var(--text-main);
    position: relative;
    z-index: 1;
}

.stat-content p {
    margin: 0.25rem 0 0 0;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

/* Modern Tables */
.table-custom {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table-custom thead {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.table-custom tr th {
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-color);
    padding: 1.25rem 1rem;
    position: relative;
}

.table-custom tr th::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--bg-gradient-primary);
    opacity: 0;
    transition: var(--transition-normal);
}

.table-custom:hover tr th::after {
    opacity: 1;
}

.table-custom tr td {
    vertical-align: middle;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1rem;
    transition: var(--transition-fast);
}

.table-custom tbody tr {
    transition: var(--transition-fast);
}

.table-custom tbody tr:hover {
    background: var(--bg-card-hover);
    transform: scale(1.002);
}

.table-custom tbody tr:hover td {
    color: var(--primary-color);
}

/* Modern Buttons */
.btn {
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
    border: none;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: var(--transition-normal);
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--bg-gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--bg-gradient-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
    color: white;
}

.btn-success {
    background: var(--bg-gradient-success);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background: var(--bg-gradient-success);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
    color: white;
}

.btn-warning {
    background: var(--bg-gradient-warning);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-warning:hover {
    background: var(--bg-gradient-warning);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.4);
    color: white;
}

.btn-danger {
    background: var(--bg-gradient-secondary);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: var(--bg-gradient-secondary);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.4);
    color: white;
}

.btn-outline-primary {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

/* Live Search Input */
.search-input-group .input-group-text {
    background: white;
    border-right: none;
}

.search-input-group .form-control {
    border-left: none;
}

.search-input-group .form-control:focus {
    box-shadow: none;
    border-color: #ced4da;
}

/* Mobile Adjustments */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .sidebar.show {
        transform: translateX(0);
    }
}