:root {
  --primary-bg: #0f172a;
  --secondary-bg: #1e293b;
  --sidebar-bg: #1e293b;
  --card-bg: #1e293b;
  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.5);
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-gold: #FFD700;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: rgba(255, 255, 255, 0.05);
  --glass-bg: rgba(255, 255, 255, 0.03);
}

body {
  background-color: var(--primary-bg) !important;
  color: var(--text-main);
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.01em;
}

/* Sidebar & Panels */
.sidebar-div {
  background-color: var(--sidebar-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.summary-panel, .alerts-panel {
  background-color: var(--secondary-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

/* Table Styling */
.table-modern {
  border-collapse: separate;
  border-spacing: 0 10px;
  margin-top: -10px;
}

.table-modern thead th {
  background-color: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: none !important;
  padding: 1rem;
}

.table-modern tbody tr {
  background: var(--glass-bg);
  transition: all 0.2s ease;
  border-radius: 12px;
}

.table-modern tbody tr:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.table-modern tbody td {
  border: none !important;
  padding: 1.25rem 1rem;
  vertical-align: middle;
  color: var(--text-main);
}

.table-modern tbody tr td:first-child { border-radius: 12px 0 0 12px; }
.table-modern tbody tr td:last-child { border-radius: 0 12px 12px 0; }

/* Dashboard Cards & Layout */
.stat-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1.5px;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-main);
}

.profit-box {
  background: linear-gradient(135deg, rgba(51, 132, 237, 0.1), rgba(51, 132, 237, 0.05));
  border: 1px solid rgba(51, 132, 237, 0.2);
  padding: 1.5rem;
  border-radius: 12px;
}

.summary-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1rem;
  transition: all 0.3s ease;
}

.summary-card:hover { border-color: var(--accent-blue); }

.summary-day {
  font-weight: 800;
  color: var(--accent-blue);
  line-height: 1;
}

.summary-date {
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
}

/* Sidebar Toggle Buttons */
.btn-stock-toggle {
  width: 100%;
  text-align: left;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
}

.btn-stock-toggle.active {
  background: rgba(59, 130, 246, 0.1) !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
  color: var(--accent-blue) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn-stock-toggle:hover:not(.active) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  transform: translateX(5px);
}

/* Nav Buttons & Sliders */
.nav-btn {
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
}

.slider-container { overflow: hidden; }
.slider-track {
  display: flex;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* DataTables Bootstrap 5 Integration Refinements */
.dataTables_wrapper .dataTables_paginate .pagination {
  margin-top: 1.5rem;
  justify-content: flex-end;
  gap: 5px;
  list-style: none !important;
  padding-left: 0 !important;
  display: flex !important;
}

.dataTables_wrapper .dataTables_paginate .pagination .page-item .page-link {
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main) !important;
  border-radius: 10px !important;
  padding: 0.5rem 1rem;
  transition: all 0.3s ease;
  font-weight: 600;
  box-shadow: none;
  text-decoration: none !important;
}

.dataTables_wrapper .dataTables_paginate .pagination .page-item.active .page-link {
  background: var(--accent-blue) !important;
  border-color: var(--accent-blue) !important;
  color: white !important;
  box-shadow: 0 4px 12px var(--accent-blue-glow);
}

.dataTables_wrapper .dataTables_paginate .pagination .page-item .page-link:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--accent-blue) !important;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
  color: var(--text-muted) !important;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-main) !important;
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  outline: none !important;
}

.dataTables_wrapper .dataTables_length select {
  padding-right: 2rem;
  margin: 0 0.5rem;
}

.dataTables_wrapper .dataTables_filter input {
  margin-left: 0.5rem;
}

.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--accent-blue) !important;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
}

/* Ensure pagination list items don't have bullets */
.pagination li { list-style: none !important; }
.pagination li::before { content: none !important; }

/* --- Critical: Override legacy style.css bright row colors --- */
.table-modern,
.table-modern * {
  background-color: transparent !important;
  background-image: none !important;
  color: var(--text-main) !important;
}

.table-modern thead th {
  background-color: transparent !important;
  color: var(--text-muted) !important;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: none !important;
  padding: 1rem;
}

.table-modern tbody tr {
  background: rgba(255, 255, 255, 0.025) !important;
  transition: all 0.2s ease;
}

.table-modern tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.04) !important;
}

.table-modern tbody tr:hover {
  background: rgba(51, 132, 237, 0.08) !important;
  transform: translateY(-1px);
}

.table-modern tbody td {
  border: none !important;
  border-top: none !important;
  border-bottom: none !important;
  padding: 0.85rem 1rem;
  vertical-align: middle;
  color: var(--text-main) !important;
}

.table-modern tbody tr td:first-child { border-radius: 12px 0 0 12px; }
.table-modern tbody tr td:last-child  { border-radius: 0 12px 12px 0; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), #2563eb) !important;
  border: none !important;
  border-radius: 12px !important;
  box-shadow: 0 4px 15px var(--accent-blue-glow) !important;
  font-weight: 600 !important;
}

.text-gold { color: var(--accent-gold) !important; }
.bg-gold { background-color: var(--accent-gold) !important; }
.text-primary { color: var(--accent-blue) !important; }

/* Override DataTables Bootstrap5's own striped/hover styles */
.table.table-modern.dataTable > tbody > tr {
  background-color: rgba(255,255,255,0.025) !important;
}

.table.table-modern.dataTable > tbody > tr.odd {
  background-color: rgba(255,255,255,0.015) !important;
}

.table.table-modern.dataTable > thead > tr > th {
  background-color: transparent !important;
  color: var(--text-muted) !important;
  border-bottom: 1px solid var(--border-color) !important;
}

/* header.php header-bar */
.header-bar {
  background-color: var(--sidebar-bg) !important;
  border-bottom: 1px solid var(--border-color) !important;
  height: 70px;
  display: flex;
  align-items: center;
}

.hbtn {
  padding: 8px 15px;
  border-radius: 12px;
  transition: all 0.3s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.hbtn:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
}

.hbtn.active {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.2);
}

.hbtn.active i {
  color: var(--accent-blue) !important;
}

.hbtn.active span {
  color: var(--accent-blue) !important;
}

.hbtn i {
  transition: all 0.3s ease;
}

.brand-text {
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--primary-bg); }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

/* Date Input Premium Styling */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.5;
    cursor: pointer;
}

.input-group-text {
    border: 1px solid var(--border-color);
}

.form-control:focus {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--accent-blue) !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
    color: white !important;
}

.select-modern {
    background-color: #1e293b !important; /* Force solid dark color */
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: var(--text-main) !important;
    border-radius: 12px !important;
    padding: 0.6rem 2.5rem 0.6rem 1rem !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 1rem center !important;
    background-size: 16px 12px !important;
    appearance: none !important;
    transition: all 0.3s ease !important;
}

.select-modern:focus {
    background-color: #1e293b !important;
    border-color: var(--accent-blue) !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15) !important;
    color: white !important;
}

.select-modern option {
    background-color: #1e293b !important;
    color: var(--text-main) !important;
    padding: 10px !important;
}

/* Global Select Fix for Dark Theme */
select, 
select.form-select, 
.select-modern {
    background-color: #1e293b !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: var(--text-main) !important;
}

select option, 
select.form-select option, 
.select-modern option {
    background-color: #1e293b !important;
    color: var(--text-main) !important;
}

/* Modals - Dark Theme Force */
.modal-content {
    background-color: #1e293b !important; /* var(--secondary-bg) */
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 24px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6) !important;
    color: #f8fafc !important;
}

.glass-modal {
    background: rgba(30, 41, 59, 0.85) !important;
    backdrop-filter: blur(16px) !important;
}

.modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    padding: 1.5rem 1.5rem 1rem !important;
}

.modal-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
    padding: 1rem 1.5rem 1.5rem !important;
}

.modal-title {
    color: #ffffff !important;
    font-weight: 800 !important;
    letter-spacing: 0.5px;
}

/* Modal Form Fields */
.modal .form-label {
    color: #94a3b8 !important; /* var(--text-muted) */
    font-size: 0.75rem !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    margin-bottom: 0.5rem !important;
}

.modal .form-control, 
.modal .form-select {
    background-color: rgba(15, 23, 42, 0.5) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    border-radius: 12px !important;
    padding: 0.75rem 1rem !important;
}

.modal .form-control:focus, 
.modal .form-select:focus {
    background-color: rgba(15, 23, 42, 0.8) !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15) !important;
    color: #ffffff !important;
}

.modal .form-control::placeholder {
    color: rgba(148, 163, 184, 0.4) !important;
}

/* Close Button Fix */
.modal .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%) !important;
    opacity: 0.8;
}

/* Utilities */
.text-muted { color: var(--text-muted) !important; }
.fw-800 { font-weight: 800; }
.ls-1 { letter-spacing: 1px; }
.smaller { font-size: 0.75rem; }
.uppercase { text-transform: uppercase; }

/* Responsive Adjustments */
@media (max-width: 991px) {
    .header-bar { height: auto; padding: 10px 0; }
    .brand-text { font-size: 1.2rem; }
}

@media (max-width: 767px) {
    /* Fix Pagination Overflow globally */
    .dataTables_wrapper .dataTables_paginate .pagination {
        flex-wrap: wrap !important;
        justify-content: center !important;
        row-gap: 8px !important;
        column-gap: 2px !important;
        margin-top: 1rem !important;
    }
    .dataTables_wrapper .dataTables_paginate .page-item .page-link {
        padding: 0.35rem 0.6rem !important;
        font-size: 0.8rem !important;
    }
    .dataTables_wrapper .dataTables_info {
        text-align: center !important;
        font-size: 0.8rem !important;
        margin-bottom: 0.5rem !important;
        width: 100% !important;
    }
    .dataTables_wrapper .dataTables_paginate {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        width: 100% !important;
    }
    
    /* Search Bar and Buttons Width Constraints */
    .dataTables_wrapper .dataTables_filter {
        text-align: center !important;
        width: 100% !important;
    }
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0.5rem 0 0 0 !important;
    }
    .dataTables_wrapper .dt-buttons {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 5px !important;
        width: 100% !important;
        margin-bottom: 10px !important;
    }
}
