/**
 * Retail ORC Analytics - Custom Styles
 * 
 * This file contains custom CSS that extends Bootstrap 5 for the
 * Retail ORC Video Analytics application.
 */

/* =============================================================================
   CSS CUSTOM PROPERTIES (VARIABLES)
   ============================================================================= */

:root {
  /* Brand Colors - Dark Theme */
  --brand-primary: #fbbf24;       /* Amber - primary accent */
  --brand-secondary: #f59e0b;     /* Darker amber */
  --brand-accent: #fcd34d;        /* Light amber */
  --brand-success: #34d399;       /* Emerald green */
  --brand-warning: #fbbf24;       /* Amber warning */
  --brand-danger: #f87171;        /* Light red */
  
  /* Neutral Colors - Dark Theme (inverted) */
  --neutral-50: #0f0f0f;          /* Almost black */
  --neutral-100: #1a1a1a;         /* Very dark gray */
  --neutral-200: #262626;         /* Dark gray */
  --neutral-300: #404040;         /* Medium dark gray */
  --neutral-400: #737373;         /* Medium gray */
  --neutral-500: #a3a3a3;         /* Light gray */
  --neutral-600: #d4d4d4;         /* Lighter gray */
  --neutral-700: #e5e5e5;         /* Very light gray */
  --neutral-800: #f5f5f5;         /* Almost white */
  --neutral-900: #ffffff;         /* Pure white */
  
  /* Typography */
  --font-family-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Monaco, 'Courier New', monospace;
  
  /* Spacing */
  --header-height: 64px;
  --sidebar-width: 280px;
  --content-max-width: 1200px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --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);
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

/* =============================================================================
   GLOBAL STYLES
   ============================================================================= */

body {
  font-family: var(--font-family-primary);
  background-color: #000000 !important;       /* Force pure black background */
  color: var(--neutral-900) !important;       /* Force white text */
  line-height: 1.6;
}

/* Force all containers to have dark background */
.container, .container-fluid, main, .main-content {
  background-color: #000000 !important;
  color: #ffffff !important;
}

/* Typography improvements */
h1, h2, h3, h4, h5, h6 {
  color: var(--neutral-900) !important;       /* Force white headings */
  font-weight: 600;
  line-height: 1.3;
}

/* Code elements */
code, pre {
  font-family: var(--font-family-mono);
  background-color: var(--neutral-100);
  color: var(--brand-primary);      /* Amber code text */
}

/* Links */
a {
  color: var(--brand-primary) !important;      /* Force amber links */
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--brand-secondary);
}

/* =============================================================================
   LAYOUT COMPONENTS
   ============================================================================= */

/* Header */
.app-header {
  background: linear-gradient(135deg, #1a1a1a, #000000);  /* Dark gradient */
  border-bottom: 2px solid var(--brand-primary);          /* Amber border */
  height: var(--header-height);
  box-shadow: 0 4px 6px -1px rgba(251, 191, 36, 0.1);    /* Amber shadow */
  position: sticky;
  top: 0;
  z-index: 1030;
}

.app-header .navbar-brand {
  color: var(--brand-primary) !important;                 /* Amber brand text */
  font-weight: 700;
  font-size: 1.25rem;
}

.app-header .navbar-brand:hover {
  color: var(--brand-accent) !important;                  /* Light amber on hover */
}

/* Logo */
.app-logo {
  height: 40px;
  width: auto;
}

/* Navigation */
.app-nav .nav-link {
  color: var(--neutral-700) !important;                   /* Light gray text */
  font-weight: 500;
  padding: 0.75rem 1rem !important;
  border-radius: var(--radius-md);
  margin: 0 0.25rem;
  transition: all 0.2s ease;
}

.app-nav .nav-link:hover,
.app-nav .nav-link.active {
  background-color: rgba(251, 191, 36, 0.1);             /* Amber background */
  color: var(--brand-primary) !important;                /* Amber text on hover/active */
}

/* User info in header */
.user-info {
  color: var(--neutral-700);                             /* Light gray user info */
  font-size: 0.875rem;
}

.user-role-badge {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

/* Back button */
.btn-back {
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  transition: all 0.2s ease;
}

.btn-back:hover {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  transform: translateX(-2px);
}

/* Main content area */
.main-content {
  min-height: calc(100vh - var(--header-height) - 60px); /* 60px for footer */
  padding-top: 2rem;
  padding-bottom: 2rem;
}

/* Footer */
.app-footer {
  background-color: var(--neutral-100);                   /* Dark footer background */
  color: var(--neutral-700);                              /* Light gray text */
  border-top: 2px solid var(--brand-primary);             /* Amber top border */
  padding: 1.5rem 0;
  margin-top: auto;
}

.app-footer a {
  color: var(--brand-primary);                            /* Amber links */
}

.app-footer a:hover {
  color: var(--brand-accent);                             /* Light amber on hover */
}

/* =============================================================================
   CARD COMPONENTS
   ============================================================================= */

.card {
  border: 1px solid var(--neutral-200);                   /* Dark border */
  border-radius: var(--radius-lg);
  background-color: var(--neutral-100);                   /* Dark card background */
  color: var(--neutral-900);                              /* White text */
  box-shadow: 0 4px 6px -1px rgba(251, 191, 36, 0.05);  /* Subtle amber shadow */
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: 0 10px 15px -3px rgba(251, 191, 36, 0.1);  /* Amber shadow on hover */
  transform: translateY(-1px);
  border-color: var(--brand-primary);                     /* Amber border on hover */
}

.card-header {
  background-color: var(--neutral-200);                   /* Darker header background */
  border-bottom: 1px solid var(--brand-primary);          /* Amber bottom border */
  font-weight: 600;
  color: var(--brand-primary);                            /* Amber header text */
}

/* Metric cards */
.metric-card {
  background: linear-gradient(135deg, var(--neutral-100), var(--neutral-200));  /* Dark gradient */
  color: var(--neutral-900);                              /* White text */
  border: 1px solid var(--brand-primary);                 /* Amber border */
}

.metric-card .card-body {
  padding: 1.5rem;
}

.metric-value {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.metric-label {
  font-size: 0.875rem;
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Alert cards */
.alert-card {
  border-left: 4px solid;
  border-radius: var(--radius-md);
}

.alert-card.alert-warning {
  border-left-color: var(--brand-warning);
  background-color: #fef3c7;
}

.alert-card.alert-danger {
  border-left-color: var(--brand-danger);
  background-color: #fee2e2;
}

.alert-card.alert-info {
  border-left-color: var(--brand-secondary);
  background-color: #dbeafe;
}

/* =============================================================================
   FORM COMPONENTS
   ============================================================================= */

.form-control {
  border: 1px solid var(--neutral-300);                   /* Dark border */
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  background-color: var(--neutral-200);                   /* Dark input background */
  color: var(--neutral-900);                              /* White text */
  transition: all 0.2s ease;
}

.form-control:focus {
  border-color: var(--brand-primary);                     /* Amber border on focus */
  background-color: var(--neutral-100);                   /* Slightly darker on focus */
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.1);        /* Amber focus shadow */
  color: var(--neutral-900);                              /* White text */
}

.form-label {
  font-weight: 500;
  color: var(--brand-primary);                            /* Amber labels */
  margin-bottom: 0.5rem;
}

/* =============================================================================
   BUTTON COMPONENTS
   ============================================================================= */

.btn {
  border-radius: var(--radius-md);
  font-weight: 500;
  padding: 0.75rem 1.5rem;
  transition: all 0.2s ease;
  color: #000000;                                         /* Black text on buttons */
}

.btn-primary {
  background-color: var(--brand-primary);                 /* Amber background */
  border-color: var(--brand-primary);
  color: #000000 !important;                              /* Black text */
}

.btn-primary:hover {
  background-color: var(--brand-secondary);               /* Darker amber on hover */
  border-color: var(--brand-secondary);
  color: #000000 !important;                              /* Keep black text */
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--neutral-300);                   /* Medium gray background */
  border-color: var(--neutral-300);
  color: var(--neutral-900) !important;                   /* White text */
}

.btn-success {
  background-color: var(--brand-success);
  border-color: var(--brand-success);
  color: #000000 !important;                              /* Black text */
}

.btn-warning {
  background-color: var(--brand-warning);
  border-color: var(--brand-warning);
  color: #000000 !important;                              /* Black text */
}

.btn-danger {
  background-color: var(--brand-danger);
  border-color: var(--brand-danger);
  color: #000000 !important;                              /* Black text */
}

/* =============================================================================
   TABLE COMPONENTS
   ============================================================================= */

.table {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background-color: var(--neutral-100);                   /* Dark table background */
  color: var(--neutral-900);                              /* White text */
  box-shadow: 0 4px 6px -1px rgba(251, 191, 36, 0.05);  /* Subtle amber shadow */
}

.table thead th {
  background-color: var(--neutral-200);                   /* Darker header background */
  border-bottom: 2px solid var(--brand-primary);          /* Amber bottom border */
  font-weight: 600;
  color: var(--brand-primary);                            /* Amber header text */
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.table tbody tr:hover {
  background-color: rgba(251, 191, 36, 0.05);            /* Subtle amber hover */
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

/* Spacing utilities */
.p-safe {
  padding: 1rem;
}

.m-safe {
  margin: 1rem;
}

/* Text utilities */
.text-muted {
  color: var(--neutral-500) !important;
}

.text-brand {
  color: var(--brand-primary) !important;
}

/* Background utilities */
.bg-gradient-primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
}

/* Loading and status indicators */
.loading-spinner {
  border: 2px solid var(--neutral-200);
  border-top: 2px solid var(--brand-secondary);
  border-radius: 50%;
  width: 1rem;
  height: 1rem;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Status badges */
.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.active {
  background-color: var(--brand-success);
  color: white;
}

.status-badge.inactive {
  background-color: var(--neutral-400);
  color: white;
}

.status-badge.warning {
  background-color: var(--brand-warning);
  color: white;
}

.status-badge.error {
  background-color: var(--brand-danger);
  color: white;
}

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

@media (max-width: 768px) {
  .app-header {
    height: auto;
    min-height: var(--header-height);
  }
  
  .main-content {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
  
  .metric-value {
    font-size: 2rem;
  }
  
  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
}

/* =============================================================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================================================= */

/* Focus indicators */
.btn:focus,
.form-control:focus,
.nav-link:focus {
  outline: 2px solid var(--brand-secondary);
  outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .card {
    border-width: 2px;
  }
  
  .btn {
    border-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =============================================================================
   BOOTSTRAP DARK THEME OVERRIDES
   ============================================================================= */

/* Modal dark theme */
.modal-content {
  background-color: var(--neutral-100) !important;
  color: var(--neutral-900) !important;
  border: 1px solid var(--brand-primary);
}

.modal-header {
  border-bottom: 1px solid var(--brand-primary);
  background-color: var(--neutral-200);
}

.modal-footer {
  border-top: 1px solid var(--brand-primary);
  background-color: var(--neutral-200);
}

/* Dropdown dark theme */
.dropdown-menu {
  background-color: var(--neutral-100) !important;
  border: 1px solid var(--brand-primary);
}

.dropdown-item {
  color: var(--neutral-900) !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: rgba(251, 191, 36, 0.1) !important;
  color: var(--brand-primary) !important;
}

/* Badge dark theme */
.badge {
  background-color: var(--brand-primary) !important;
  color: #000000 !important;
}

/* Alert dark theme */
.alert {
  background-color: var(--neutral-100) !important;
  border: 1px solid var(--brand-primary);
  color: var(--neutral-900) !important;
}

/* Navbar toggler for dark theme */
.navbar-toggler {
  border-color: var(--brand-primary) !important;
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28251, 191, 36, 1%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

/* =============================================================================
   FORCE DARK THEME - HIGHEST PRIORITY OVERRIDES
   ============================================================================= */

/* Force dark theme with highest specificity */
html, body, .container, .container-fluid, main, .main-content, .row, .col, div {
  background-color: #000000 !important;
  color: #ffffff !important;
}

/* Force dark header */
.app-header, .navbar, .navbar-dark {
  background: linear-gradient(135deg, #1a1a1a, #000000) !important;
  border-bottom: 2px solid #fbbf24 !important;
}

/* Force amber brand and navigation */
.navbar-brand, .nav-link {
  color: #fbbf24 !important;
}

.nav-link:hover, .nav-link:focus {
  color: #fcd34d !important;
  background-color: rgba(251, 191, 36, 0.1) !important;
}

/* Force card dark theme */
.card {
  background-color: #1a1a1a !important;
  border: 1px solid #fbbf24 !important;
  color: #ffffff !important;
}

.card-header {
  background-color: #262626 !important;
  border-bottom: 1px solid #fbbf24 !important;
  color: #fbbf24 !important;
}

/* Force metric cards */
.metric-card {
  background: linear-gradient(135deg, #1a1a1a, #262626) !important;
  border: 1px solid #fbbf24 !important;
  color: #ffffff !important;
}

/* Force text colors */
p, span, div, td, th, li, label {
  color: #ffffff !important;
}

/* Force headings */
h1, h2, h3, h4, h5, h6 {
  color: #ffffff !important;
}

/* Force footer */
.app-footer {
  background-color: #1a1a1a !important;
  border-top: 2px solid #fbbf24 !important;
  color: #ffffff !important;
}