html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

:root {
  --primary-color: #1976d2;
  --primary-dark: #1565c0;
  --primary-light: #42a5f5;
  --background-color: #fafafa;
  --surface-color: #ffffff;
  --text-primary: #212121;
  --text-secondary: #757575;
}

body {
  margin-bottom: 60px;
  background-color: var(--background-color);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.dark-theme {
  --background-color: #1a1a1a;
  --surface-color: #2d2d2d;
  --text-primary: #ffffff;
  --text-secondary: #cccccc;
}

.dark-theme .navbar {
  background-color: var(--primary-dark) !important;
}

.dark-theme .card {
  background-color: var(--surface-color);
  border-color: #444;
}

.dark-theme .table {
  color: var(--text-primary);
  background-color: var(--surface-color);
}

.dark-theme .table-hover tbody tr:hover {
  background-color: rgba(66, 165, 245, 0.2);
}

.dark-theme .text-muted {
  color: var(--text-secondary) !important;
}

.dark-theme .table-primary {
  background-color: var(--primary-color) !important;
}

/* Professional Theme - Navy & Gray */
.professional-theme {
  --background-color: #f5f7fa;
  --surface-color: #ffffff;
  --text-primary: #2c3e50;
  --text-secondary: #7f8c8d;
  --primary-color: #34495e;
  --primary-dark: #2c3e50;
}

.professional-theme .navbar {
  background-color: #34495e !important;
}

.professional-theme .card {
  background-color: var(--surface-color);
  border: 1px solid #e1e8ed;
}

.professional-theme .table {
  color: var(--text-primary);
  font-size: 15px;
}

.professional-theme .table-hover tbody tr:hover {
  background-color: #ecf0f1;
}

.professional-theme .bg-primary {
  background-color: #34495e !important;
}

/* Modern Theme - Teal & White */
.modern-theme {
  --background-color: #fafbfc;
  --surface-color: #ffffff;
  --text-primary: #1a202c;
  --text-secondary: #718096;
  --primary-color: #0891b2;
  --primary-dark: #0e7490;
}

.modern-theme .navbar {
  background-color: #0891b2 !important;
}

.modern-theme .card {
  background-color: var(--surface-color);
  border: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.modern-theme .table {
  color: var(--text-primary);
  font-size: 15px;
}

.modern-theme .table-hover tbody tr:hover {
  background-color: #f0fdfa;
}

.modern-theme .bg-primary {
  background-color: #0891b2 !important;
}

/* High Contrast Theme - Black & White for distance viewing */
.high-contrast-theme {
  --background-color: #ffffff;
  --surface-color: #ffffff;
  --text-primary: #000000;
  --text-secondary: #333333;
  --primary-color: #000000;
  --primary-dark: #000000;
}

.high-contrast-theme .navbar {
  background-color: #000000 !important;
}

.high-contrast-theme .card {
  background-color: var(--surface-color);
  border: 3px solid #000000;
}

.high-contrast-theme .table {
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 500;
  border: 2px solid #000000;
}

.high-contrast-theme .table thead {
  border-bottom: 3px solid #000000;
}

.high-contrast-theme .table tbody tr {
  border-bottom: 2px solid #000000;
}

.high-contrast-theme .table-hover tbody tr:hover {
  background-color: #f0f0f0;
}

.high-contrast-theme .bg-primary {
  background-color: #000000 !important;
}

.high-contrast-theme .text-primary {
  color: #000000 !important;
}

.high-contrast-theme .btn-outline-primary {
  color: #000000;
  border-color: #000000;
  border-width: 2px;
}

/* Factory Display Theme - Large text, status badges, high visibility */
.factory-display-theme {
  --background-color: #f0f0f0;
  --surface-color: #ffffff;
  --text-primary: #000000;
  --text-secondary: #555555;
  --primary-color: #1976d2;
  --primary-dark: #1565c0;
}

.factory-display-theme body {
  font-size: 20px;
}

.factory-display-theme .table {
  font-size: 20px;
  font-weight: 500;
}

.factory-display-theme .table td,
.factory-display-theme .table th {
  padding: 20px 15px;
}

.factory-display-theme .card {
  background-color: var(--surface-color);
  border: 2px solid #ddd;
}

.factory-display-theme h2 {
  font-size: 32px;
  font-weight: bold;
}

/* Status Badges */
.status-badge {
  font-size: 13px;
  padding: 6px 13px;
  font-weight: 600;
  border-radius: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.factory-display-theme .status-badge {
  font-size: 14px;
  padding: 8px 16px;
}

.status-pending {
  background-color: #ffc107;
  color: #000000;
}

.status-processed {
  background-color: #2196f3;
  color: #ffffff;
}

.status-complete {
  background-color: #4caf50;
  color: #ffffff;
}

.status-delivered {
  background-color: #2e7d32;
  color: #ffffff;
}

.status-open {
  background-color: #03a9f4;
  color: #ffffff;
}

.status-cancelled {
  background-color: #f44336;
  color: #ffffff;
}

/* Alternating Row Colors */
.alternating-rows .table tbody tr:nth-child(odd) {
  background-color: #f9f9f9;
}

.alternating-rows .table tbody tr:nth-child(even) {
  background-color: #ffffff;
}

.alternating-rows.dark-theme .table tbody tr:nth-child(odd) {
  background-color: #2a2a2a;
}

.alternating-rows.dark-theme .table tbody tr:nth-child(even) {
  background-color: #1e1e1e;
}

/* Highlight Animations */
@keyframes highlightNew {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(76, 175, 80, 0.6); }
}

@keyframes highlightStatus {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(33, 150, 243, 0.6); }
}

@keyframes highlightItem {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(255, 193, 7, 0.6); }
}

.highlight-new {
  animation: highlightNew 2s ease-in-out 3;
  box-shadow: 0 0 25px rgba(76, 175, 80, 0.8), inset 0 0 20px rgba(76, 175, 80, 0.3);
  border-left: 5px solid #4caf50;
}

.highlight-status {
  animation: highlightStatus 2s ease-in-out 3;
  box-shadow: 0 0 25px rgba(33, 150, 243, 0.8), inset 0 0 20px rgba(33, 150, 243, 0.3);
  border-left: 5px solid #2196f3;
}

.highlight-item {
  animation: highlightItem 2s ease-in-out 3;
  box-shadow: 0 0 25px rgba(255, 193, 7, 0.8), inset 0 0 20px rgba(255, 193, 7, 0.3);
  border-left: 5px solid #ffc107;
}

/* Fullscreen mode - hide header/footer */
.factory-display-theme:fullscreen .navbar,
.factory-display-theme:fullscreen .footer {
  display: none;
}

.dark-theme .footer {
  background-color: var(--surface-color);
  border-top-color: #444 !important;
}

.dark-theme .btn-outline-primary {
  color: var(--primary-light);
  border-color: var(--primary-light);
}

.dark-theme .btn-outline-primary:hover {
  background-color: var(--primary-light);
  color: #000;
}

/* Context Menu Styling */
#contextMenu {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.dark-theme #contextMenu {
  background-color: #2d2d2d;
  border-color: #444;
  color: #ffffff;
}

.dark-theme #contextMenu > div:first-child {
  background-color: #1a1a1a;
  border-bottom-color: #444;
}

.dark-theme #contextMenu .form-select {
  background-color: #1a1a1a;
  color: #ffffff;
  border-color: #444;
}

.professional-theme #contextMenu,
.modern-theme #contextMenu,
.high-contrast-theme #contextMenu,
.factory-display-theme #contextMenu {
  background-color: var(--surface-color);
  color: var(--text-primary);
}

/* Force High Contrast Mode */
.force-high-contrast {
  background-color: #ffffff !important;
  color: #000000 !important;
}

.force-high-contrast .table {
  background-color: #ffffff !important;
  color: #000000 !important;
  border: 2px solid #000000 !important;
}

.force-high-contrast .table thead {
  background-color: #000000 !important;
  color: #ffffff !important;
}

.force-high-contrast #drillDownTable thead {
  background-color: #ffffff !important;
  color: #000000 !important;
  border-bottom: 2px solid #000000 !important;
}

.force-high-contrast .table tbody tr {
  border-bottom: 1px solid #000000 !important;
}

.force-high-contrast .table-hover tbody tr:hover {
  background-color: #f0f0f0 !important;
}

.force-high-contrast .card {
  background-color: #ffffff !important;
  border: 2px solid #000000 !important;
}

/* Force scrollbar to always show to prevent column shifting */
html {
  overflow-y: scroll;
}

/* Fixed table layout to prevent column shifting during paging */
#salesOrderTable {
  table-layout: fixed;
  width: 100%;
}

#salesOrderTable th:nth-child(1),
#salesOrderTable td:nth-child(1) {
  width: 30px !important;
  max-width: 30px !important;
  min-width: 30px !important;
  text-align: center !important;
  padding: 4px !important;
  overflow: hidden !important;
}

#salesOrderTable .star-btn {
  padding: 0 !important;
  margin: 0 !important;
  line-height: 1 !important;
}

#salesOrderTable .star-btn .material-icons {
  font-size: 16px !important;
}

#salesOrderTable th:nth-child(2),
#salesOrderTable td:nth-child(2) {
  width: 50%;
}

#salesOrderTable th:nth-child(3),
#salesOrderTable td:nth-child(3) {
  width: 25%;
}

#salesOrderTable th:nth-child(4),
#salesOrderTable td:nth-child(4) {
  width: 25%;
}

.bg-primary {
  background-color: var(--primary-color) !important;
}

.text-primary {
  color: var(--primary-color) !important;
}

.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.btn-outline-primary {
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.table-primary {
  background-color: var(--primary-color);
  color: white;
}

.card {
  background-color: var(--surface-color);
  border: none;
  border-radius: 8px;
}

.material-icons {
  vertical-align: middle;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--primary-color);
}

html {
  position: relative;
  min-height: 100%;
}

/* Column Resizer */
.column-resizer {
  position: absolute;
  right: 0;
  top: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 10;
  background-color: rgba(255, 255, 255, 0.3);
  border-right: 2px solid rgba(255, 255, 255, 0.5);
}

.column-resizer:hover {
  background-color: var(--primary-color);
  border-right: 2px solid var(--primary-color);
  opacity: 0.8;
}

#salesOrderTable thead th {
  position: relative;
  overflow: visible;
}

/* Urgent Order Styling - Override all themes */
#salesOrderTable td[style*="#dc3545"],
#salesOrderTable td[style*="color: #dc3545"],
.urgent-order {
  color: #dc3545 !important;
  font-weight: bold !important;
}

/* Ensure urgent styling persists across all themes */
.dark-theme #salesOrderTable td[style*="#dc3545"],
.professional-theme #salesOrderTable td[style*="#dc3545"],
.modern-theme #salesOrderTable td[style*="#dc3545"],
.high-contrast-theme #salesOrderTable td[style*="#dc3545"],
.factory-display-theme #salesOrderTable td[style*="#dc3545"],
.force-high-contrast #salesOrderTable td[style*="#dc3545"] {
  color: #dc3545 !important;
  font-weight: bold !important;
}
