:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topbar-height: 60px;
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-sidebar: #1e293b;
    --bg-sidebar-hover: #334155;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-sidebar: #e2e8f0;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 8px;
    --radius-lg: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.erp-body {
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: var(--topbar-height);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-sidebar);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.125rem;
}

.sidebar-brand:hover {
    color: #ffffff;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.sidebar-brand-text {
    white-space: nowrap;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-sidebar);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
}

.sidebar-toggle:hover {
    background: var(--bg-sidebar-hover);
    color: #ffffff;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin: 0.25rem 0.75rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-sidebar);
    text-decoration: none;
    border-radius: var(--radius);
    position: relative;
}

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

.nav-link.active {
    background: var(--primary-color);
    color: #ffffff;
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1.125rem;
}

.nav-text {
    white-space: nowrap;
    font-weight: 500;
}

.nav-link-toggle {
    position: relative;
    cursor: pointer;
}

.nav-link-toggle .fa-chevron-down {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
    margin-left: auto;
}

.nav-link-toggle[aria-expanded="true"] .fa-chevron-down {
    transform: rotate(180deg);
}

.nav-item-parent {
    position: relative;
}

.nav-submenu {
    list-style: none;
    padding-left: 0;
    background: rgba(0, 0, 0, 0.2);
    margin: 0;
}

.nav-submenu .nav-item {
    margin: 0;
}

.nav-submenu .nav-link {
    padding-left: 3rem;
    font-size: 0.875rem;
}

.nav-submenu .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    padding-left: 3.5rem;
}

.nav-submenu .nav-link.active {
    background: var(--primary-color);
    color: #ffffff;
}

.nav-divider {
    padding: 0.75rem 1.25rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.5px;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

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

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Bar */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
}

.topbar-toggle:hover {
    background: var(--bg-secondary);
}

.topbar-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
}

.topbar-user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.user-info-item {
    display: flex;
    align-items: center;
}

.user-info-item i {
    color: var(--primary-color);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 1.5rem;
}

/* Cards */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.card-body {
    padding: 1.5rem;
}

/* Buttons */
.btn {
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    font-weight: 500;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    color: #ffffff;
}

.btn-success {
    background: var(--success-color);
    color: #ffffff;
}

.btn-danger {
    background: var(--danger-color);
    color: #ffffff;
}

.btn-outline-primary {
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: #ffffff;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-link {
    color: var(--primary-color);
    text-decoration: none;
}

.btn-link:hover {
    color: var(--primary-hover);
}

/* Forms */
.form-control,
.form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    background: var(--bg-primary);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

/* Tables */
.table {
    background: var(--bg-primary);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 0;
}

.table thead {
    background: var(--bg-secondary);
}

.table thead th {
    border-bottom: 2px solid var(--border-color);
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.table tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: var(--bg-secondary);
}

/* Alerts */
.alert {
    border-radius: var(--radius);
    border: none;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
}

.alert i {
    margin-right: 0.75rem;
}

/* Badges */
.badge {
    padding: 0.375rem 0.75rem;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.75rem;
}

.badge-success {
    background: var(--success-color);
    color: #ffffff;
}

.badge-danger {
    background: var(--danger-color);
    color: #ffffff;
}

.badge-warning {
    background: var(--warning-color);
    color: #ffffff;
}

/* Stats Cards */
.stats-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.stats-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stats-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #ffffff;
    margin-bottom: 1rem;
}

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

.icon-success {
    background: var(--success-color);
}

.icon-danger {
    background: var(--danger-color);
}

.icon-warning {
    background: var(--warning-color);
}

.stats-card h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stats-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    background: var(--bg-primary);
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: var(--bg-secondary);
}

.upload-area.dragover {
    border-color: var(--success-color);
    background: #d1fae5;
}

.file-input {
    display: none;
}

.file-label {
    font-weight: 500;
    color: var(--text-primary);
}

.file-label.has-file {
    color: var(--success-color);
    font-weight: 600;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.loading-content {
    text-align: center;
}

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar-brand-text {
        display: none;
    }
    
    .nav-text {
        display: block;
    }
}

@media (max-width: 767.98px) {
    .page-content {
        padding: 1rem;
    }
    
    .topbar {
        padding: 0 1rem;
    }
    
    .topbar-title {
        font-size: 1.125rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .stats-card {
        padding: 1.25rem;
    }
    
    .upload-area {
        padding: 2rem 1.5rem;
    }
    
    .table-responsive {
        font-size: 0.8125rem;
    }
}

/* Login Page Styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    max-width: 420px;
    width: 100%;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-card .card-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    text-align: center;
    padding: 2rem;
    border: none;
}

.login-card .card-header i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.login-card .card-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.login-card .card-body {
    padding: 2rem;
}

/* Utilities */
.text-muted {
    color: var(--text-secondary) !important;
}

.shadow-sm {
    box-shadow: var(--shadow-sm) !important;
}

.shadow {
    box-shadow: var(--shadow) !important;
}

.shadow-md {
    box-shadow: var(--shadow-md) !important;
}

.shadow-lg {
    box-shadow: var(--shadow-lg) !important;
}



/* Print Styles */
@media print {
    .sidebar,
    .topbar,
    .btn,
    .alert {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .page-content {
        padding: 0 !important;
    }
}

/* Autocomplete Styles */
.autocomplete {
    position: relative;
    display: inline-block;
    width: 100%;
}

.autocomplete.flex-grow-1 {
    flex: 1 1 auto;
}

.autocomplete-items {
    position: absolute;
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-primary);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius);
    max-height: 300px;
    overflow-y: auto;
    margin-top: 2px;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.autocomplete-item:first-child {
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}

.autocomplete-item:last-child {
    border-bottom: none;
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.autocomplete-item:hover,
.autocomplete-active {
    background-color: var(--primary-color);
    color: #ffffff;
}

.autocomplete-item small {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.autocomplete-item:hover small,
.autocomplete-active small {
    color: rgba(255, 255, 255, 0.8);
}
