:root {
    --primary-color: #3b7ddd;
    --secondary-color: #6c757d;
    --success-color: #1cbb8c;
    --danger-color: #fc5b69;
    --warning-color: #f7b84b;
    --info-color: #5ac1dd;
    --sidebar-width: 250px;
}

body {
    font-size: .875rem;
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    width: var(--sidebar-width);
    padding: 48px 0 0;
    background-color: #2a3042;
    color: #a6b0cf;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    transition: all 0.3s;
}

.sidebar .nav-link {
    font-weight: 500;
    color: #a6b0cf;
    padding: 12px 20px;
    margin: 4px 0;
    border-left: 3px solid transparent;
}

.sidebar .nav-link:hover, 
.sidebar .nav-link.active {
    color: #fff;
    background-color: #3b7ddd;
    border-left-color: #fff;
}

.sidebar-heading {
    font-size: .75rem;
    text-transform: uppercase;
}

.navbar-brand {
    padding-top: .75rem;
    padding-bottom: .75rem;
    font-size: 1rem;
    background-color: rgba(0, 0, 0, .25);
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25);
}

.navbar .form-control {
    padding: .75rem 1rem;
    border-width: 0;
    border-radius: 0;
}

.form-control-dark {
    color: #fff;
    background-color: rgba(255, 255, 255, .1);
    border-color: rgba(255, 255, 255, .1);
}

.form-control-dark:focus {
    border-color: transparent;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);
}

.bd-placeholder-img {
    font-size: 1.125rem;
    text-anchor: middle;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

@media (min-width: 768px) {
    .bd-placeholder-img-lg {
        font-size: 3.5rem;
    }
}

.b-example-divider {
    height: 3rem;
    background-color: rgba(0, 0, 0, .1);
    border: solid rgba(0, 0, 0, .15);
    border-width: 1px 0;
    box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15);
}

.b-example-vr {
    flex-shrink: 0;
    width: 1.5rem;
    height: 100vh;
}

.bi {
    vertical-align: -.125em;
    fill: currentColor;
}

.nav-scroller {
    position: relative;
    z-index: 2;
    height: 2.75rem;
    overflow-y: hidden;
}

.nav-scroller .nav {
    display: flex;
    flex-wrap: nowrap;
    padding-bottom: 1rem;
    margin-top: -1px;
    overflow-x: auto;
    text-align: center;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Main content area */
main {
    margin-left: var(--sidebar-width);
    padding: 20px;
    transition: all 0.3s;
}

.header {
    background-color: #fff;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    padding: 15px 20px;
    margin-bottom: 20px;
}

/* Card styling */
.card {
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.1);
    border: 1px solid #e3e6f0;
    margin-bottom: 20px;
    border-radius: 0.5rem;
}

.card-header {
    border-bottom: 1px solid #e3e6f0;
    padding: 1rem 1.25rem;
    background-color: #f8f9fc;
    font-weight: 600;
    color: #4e73df;
}

.card-header.bg-primary {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%) !important;
    border: none;
    color: white;
}

.card-header.bg-light {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
}

/* Table styling */
.table th {
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    background-color: #eaecf4;
    color: #4e73df;
    border: none;
}

.table-hover tbody tr:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

.batch-highlight {
    background-color: rgba(59, 125, 221, 0.1) !important;
}

/* Badge styling */
.badge {
    font-size: 0.75em;
    padding: 0.5em 0.75em;
    border-radius: 0.5rem;
}

.badge.bg-success {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%) !important;
}

.badge.bg-warning {
    background: linear-gradient(135deg, #f39c12 0%, #f1c40f 100%) !important;
    color: #2c3e50;
}

/* Button styling */
.btn-primary {
    background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
    border: none;
    border-radius: 0.375rem;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2471a3 0%, #2980b9 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-outline-secondary {
    border-radius: 0.375rem;
}

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

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

/* Form styling */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.form-control {
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
    padding: 0.5rem 0.75rem;
}

.form-control:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

/* Alert styling */
.alert {
    border-radius: 0.5rem;
    border: none;
}

.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
}

/* DataTables customization */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 1rem;
}

.dataTables_wrapper .dataTables_info {
    padding-top: 1rem;
    color: #6c757d;
}

.dataTables_wrapper .dataTables_paginate {
    padding-top: 0.5rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 0.375rem !important;
    margin-left: 0.125rem;
    margin-right: 0.125rem;
}

.batch-info {
    background-color: #f8f9fc;
    border-left: 4px solid var(--primary-color);
    padding: 15px;
    margin-bottom: 20px;
}

.action-buttons .btn {
    margin-right: 5px;
}

.batch-filter {
    max-width: 300px;
}

.stats-card {
    text-align: center;
    padding: 15px;
}

.stats-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.stats-label {
    font-size: 14px;
    color: var(--secondary-color);
}

/* Header specific fixes */
.navbar {
    position: sticky;
    z-index: 1030; /* Higher than sidebar */
}

.navbar-nav .dropdown-menu {
    position: absolute;
    right: 0;
    left: auto;
    z-index: 1031; /* Higher than navbar */
    margin-top: 0.5rem;
}

/* Ensure the dropdown toggle doesn't affect layout */
.nav-item.dropdown {
    position: static; /* Changed from default */
}

@media (min-width: 768px) {
    .nav-item.dropdown {
        position: relative;
    }
}

/* Prevent header from expanding */
.navbar-brand {
    flex-shrink: 0;
}

.navbar-nav {
    flex-shrink: 0;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
        margin-bottom: 20px;
    }
    
    main {
        margin-left: 0;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn-toolbar {
        margin-top: 1rem;
    }
    
    .d-md-flex .btn {
        margin-bottom: 0.5rem;
    }
    
    .table-responsive {
        border: none;
    }
    
    #codesTable {
        font-size: 0.875rem;
    }
    
    .dataTables_wrapper .row {
        margin-bottom: 0.5rem;
    }
    
    .dataTables_length label, 
    .dataTables_filter label {
        display: block;
        width: 100%;
    }
    
    .dataTables_length select,
    .dataTables_filter input {
        width: 100%;
        margin-top: 0.25rem;
    }
    
    /* Mobile dropdown fix */
    .navbar-nav .dropdown-menu {
        position: absolute;
        right: 0;
        left: auto;
        width: 200px;
    }
}

/* Toggle form animation */
.code-form-card {
    transition: all 0.3s ease;
}

/* Custom scrollbar for table */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}










/* Fix for mobile sidebar and navbar */
@media (max-width: 768px) {
  /* Hide sidebar by default on mobile */
  .sidebar {
    position: fixed;
    top: 56px; /* Height of navbar */
    left: -100%;
    width: 280px;
    height: calc(100vh - 56px);
    z-index: 1020;
    transition: all 0.3s ease-in-out;
    overflow-y: auto;
  }
  
  /* Show sidebar when toggled */
  .sidebar.collapse.show {
    left: 0;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.2);
  }
  
  /* Prevent body scrolling when sidebar is open */
  body.sidebar-open {
    overflow: hidden;
  }
  
  /* Adjust main content area */
  main {
    margin-left: 0;
    padding-top: 70px; /* Account for fixed header */
    transition: all 0.3s;
  }
  
  /* Overlay for when sidebar is open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1015;
  }
  
  .sidebar-overlay.show {
    display: block;
  }
  
  /* Navbar fixes */
  .navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    padding: 0.5rem 1rem;
  }
  
  .navbar-brand {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0;
    margin: 0;
    width: auto;
    z-index: 1031;
    background-color: transparent;
    box-shadow: none;
  }
  
  .navbar-toggler {
    position: relative;
    z-index: 1032;
    margin-right: auto;
  }
  
  /* User menu adjustments */
  .navbar-nav .nav-item.dropdown {
    margin-left: auto;
  }
  
  /* Ensure dropdown menus appear above sidebar */
  .navbar-nav .dropdown-menu {
    z-index: 1035;
  }
}