/* ==========================================================================
   ENTERPRISE POS DASHBOARD - PREMIUM STYLESHEET
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. COLOR SYSTEM & CSS VARIABLES
   -------------------------------------------------------------------------- */
:root {
  /* Original CSS Variables Preserved */
  --primary: #2563eb;
  --secondary: #1e40af;
  --bg: #f8fafc;
  --text: #0f172a;
  --white: #ffffff;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #d97706;
  --purple: #7c3aed;

  /* Extended Enterprise Color System */
  --danger: #dc2626;
  --info: #0284c7;
  --card-bg: rgba(255, 255, 255, 0.9);
  --sidebar-bg: #1e293b;
  --navbar-bg: rgba(255, 255, 255, 0.85);
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 15px rgba(37, 99, 235, 0.35);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  --gradient-header: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
  --gradient-card: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.85) 100%);
  --gradient-accent: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);

  /* Glassmorphism */
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(255, 255, 255, 0.3);
  --glass-blur: blur(12px);

  /* Radius & Transitions */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables Override */
[data-theme="dark"], body.dark-mode {
  --bg: #0f172a;
  --text: #f8fafc;
  --white: #1e293b;
  --border: #334155;
  --card-bg: rgba(30, 41, 59, 0.85);
  --navbar-bg: rgba(15, 23, 42, 0.85);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  --glass-bg: rgba(30, 41, 59, 0.8);
  --glass-border: rgba(255, 255, 255, 0.1);
  --gradient-header: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

/* --------------------------------------------------------------------------
   2. TYPOGRAPHY & GLOBAL STYLES
   -------------------------------------------------------------------------- */
* { 
  box-sizing: border-box; 
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body { 
  font-family: 'Plus Jakarta Sans', 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
  background-color: var(--bg); 
  color: var(--text); 
  margin: 0; 
  padding: 12px; 
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

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

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.03);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
  transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

/* --------------------------------------------------------------------------
   3. CONTAINER & LAYOUT
   -------------------------------------------------------------------------- */
.container { 
  max-width: 1400px; 
  margin: 0 auto; 
  display: none; 
  width: 100%; 
  animation: fadeIn 0.4s ease-out forwards;
}

/* --------------------------------------------------------------------------
   4. LOGIN OVERLAY
   -------------------------------------------------------------------------- */
.login-overlay { 
  position: fixed; 
  top: 0; 
  left: 0; 
  width: 100%; 
  height: 100%; 
  background: radial-gradient(circle at top left, #3b82f6, #1e3a8a); 
  display: flex; 
  justify-content: center; 
  align-items: center; 
  z-index: 9999; 
  padding: 15px; 
  backdrop-filter: blur(8px);
}

.login-box { 
  background: var(--white); 
  padding: 35px 25px; 
  border-radius: var(--radius-lg); 
  box-shadow: var(--shadow-lg); 
  width: 100%; 
  max-width: 380px; 
  text-align: center; 
  border: 1px solid var(--border);
  animation: zoomIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.login-box h2 {
  margin-bottom: 20px;
  color: var(--primary);
}

.login-box input { 
  width: 100%; 
  padding: 12px 15px; 
  margin: 10px 0; 
  border: 1px solid var(--border); 
  border-radius: var(--radius-sm); 
  box-sizing: border-box; 
  font-size: 16px; 
  background: var(--bg);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.login-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
  background: var(--white);
}

.login-btn { 
  width: 100%; 
  padding: 12px; 
  background: var(--gradient-primary); 
  color: white; 
  border: none; 
  border-radius: var(--radius-sm); 
  font-weight: 700; 
  cursor: pointer; 
  font-size: 1rem; 
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow);
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.login-btn:active {
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   5. HEADER & DASHBOARD NAVBAR
   -------------------------------------------------------------------------- */
.header { 
  background: var(--gradient-header); 
  color: var(--white); 
  padding: 18px 24px; 
  border-radius: var(--radius-lg); 
  margin-bottom: 20px; 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  box-shadow: var(--shadow-lg); 
  flex-wrap: wrap; 
  gap: 15px;
  position: sticky;
  top: 10px;
  z-index: 100;
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all var(--transition-normal);
}

.header-left { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
}

.shop-selector { 
  padding: 8px 12px; 
  border-radius: var(--radius-sm); 
  border: 1px solid rgba(255,255,255,0.3); 
  font-weight: bold; 
  color: var(--text-primary); 
  background: var(--white);
  outline: none; 
  max-width: 100%; 
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.header-search-bar input {
  background: rgba(255, 255, 255, 0.2) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  backdrop-filter: blur(4px);
}

.header-search-bar input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.header-search-bar input:focus {
  background: var(--white) !important;
  color: var(--text-primary) !important;
}

.header-btn-group { 
  display: flex; 
  gap: 10px; 
  flex-wrap: wrap; 
  align-items: center;
}

/* --------------------------------------------------------------------------
   6. BUTTONS & ACTIONS
   -------------------------------------------------------------------------- */
.btn { 
  padding: 10px 16px; 
  border: none; 
  border-radius: var(--radius-sm); 
  cursor: pointer; 
  font-weight: 600; 
  color: white; 
  transition: all var(--transition-fast); 
  font-size: 0.9rem; 
  display: inline-flex; 
  align-items: center; 
  gap: 8px; 
  justify-content: center;
  box-shadow: var(--shadow-sm);
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  filter: brightness(1.08);
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-purchase { background-color: var(--purple); }
.btn-invoice { background-color: var(--white); color: var(--primary); }
.btn-history { background-color: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.4); backdrop-filter: blur(4px); }
.btn-in-history { background-color: var(--warning); }
.close-btn { transition: background-color var(--transition-fast); }

.mobile-menu-btn {
  color: var(--white);
  transition: transform var(--transition-fast);
}

.mobile-menu-btn:hover {
  transform: scale(1.1);
}

/* --------------------------------------------------------------------------
   7. SUMMARY CARDS & DASHBOARD
   -------------------------------------------------------------------------- */
.dashboard { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); 
  gap: 16px; 
  margin-bottom: 25px; 
}

.card { 
  background: var(--card-bg); 
  padding: 18px; 
  border-radius: var(--radius-md); 
  box-shadow: var(--shadow); 
  text-align: center; 
  display: flex; 
  flex-direction: column; 
  justify-content: center; 
  align-items: center;
  border: 1px solid var(--border);
  backdrop-filter: var(--glass-blur);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--gradient-primary);
  opacity: 0.8;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(37, 99, 235, 0.3);
}

.card h3, .card h4 { 
  margin: 0; 
  font-size: 0.95rem; 
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card .value { 
  font-size: 1.75rem; 
  font-weight: 800; 
  color: var(--primary); 
  margin-top: 8px; 
  letter-spacing: -0.02em;
}

/* --------------------------------------------------------------------------
   8. QUICK ACTION & TOOLBARS
   -------------------------------------------------------------------------- */
.quick-action-panel, .inventory-toolbar, .import-export-panel {
  animation: fadeIn 0.3s ease-in-out;
}

.toolbar-filters select, .toolbar-filters input {
  background: var(--white);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   9. INPUT PANELS & FORMS
   -------------------------------------------------------------------------- */
.input-panel { 
  background: var(--card-bg); 
  padding: 18px; 
  border-radius: var(--radius-md); 
  margin-bottom: 20px; 
  box-shadow: var(--shadow); 
  border: 1px solid var(--border);
  backdrop-filter: var(--glass-blur);
}

.form-grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); 
  gap: 15px; 
  align-items: end;
}

input, select, textarea { 
  width: 100%; 
  padding: 10px 14px; 
  border: 1px solid var(--border); 
  border-radius: var(--radius-sm); 
  box-sizing: border-box; 
  font-size: 15px !important; 
  background-color: var(--white);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* --------------------------------------------------------------------------
   10. TABLES & DATA LISTS
   -------------------------------------------------------------------------- */
.table-responsive { 
  width: 100%; 
  overflow-x: auto; 
  background: var(--card-bg); 
  border-radius: var(--radius-md); 
  box-shadow: var(--shadow); 
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch; 
  backdrop-filter: var(--glass-blur);
}

table { 
  width: 100%; 
  border-collapse: collapse; 
  min-width: 650px; 
}

thead { 
  background-color: rgba(241, 245, 249, 0.8); 
  border-bottom: 2px solid var(--border); 
  position: sticky;
  top: 0;
  z-index: 10;
}

[data-theme="dark"] thead {
  background-color: #1e293b;
}

th, td { 
  padding: 12px 14px; 
  text-align: left; 
  border-bottom: 1px solid var(--border); 
  font-size: 0.9rem; 
  word-break: break-word; 
}

th {
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
}

tbody tr {
  transition: background-color var(--transition-fast);
}

tbody tr:hover {
  background-color: rgba(37, 99, 235, 0.04);
}

.stock-badge { 
  padding: 4px 10px; 
  border-radius: 20px; 
  font-size: 0.78rem; 
  font-weight: 700; 
  display: inline-block; 
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stock-low { 
  background-color: #fef3c7; 
  color: #b45309; 
  border: 1px solid #fde68a;
}

.stock-out { 
  background-color: #fee2e2; 
  color: #b91c1c; 
  border: 1px solid #fca5a5;
}

.good-stock { 
  background-color: #dcfce7; 
  color: #15803d; 
  border: 1px solid #86efac;
}

/* --------------------------------------------------------------------------
   11. MODALS & INVOICES
   -------------------------------------------------------------------------- */
.modal { 
  display: none; 
  position: fixed; 
  z-index: 1000; 
  left: 0; 
  top: 0; 
  width: 100%; 
  height: 100%; 
  background-color: rgba(15, 23, 42, 0.6); 
  backdrop-filter: blur(6px);
  overflow-y: auto; 
  padding: 15px 10px; 
  box-sizing: border-box; 
  align-items: center; 
  justify-content: center; 
  animation: fadeIn 0.25s ease-out;
}

.modal-content { 
  background-color: var(--white); 
  color: var(--text-primary);
  margin: auto; 
  padding: 24px 20px; 
  width: 100%; 
  max-width: 210mm; 
  border-radius: var(--radius-lg); 
  position: relative; 
  max-height: 92vh; 
  overflow-y: auto; 
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.invoice-paper { 
  width: 100%; 
  position: relative; 
  padding: 20px; 
  box-sizing: border-box; 
  background: #ffffff; 
  color: #0f172a;
  border-radius: var(--radius-md);
  box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

.invoice-header { 
  text-align: center; 
  border-bottom: 2px solid #0f172a; 
  padding-bottom: 12px; 
  margin-bottom: 18px; 
}

.invoice-info-grid { 
  display: flex; 
  justify-content: space-between; 
  margin-bottom: 18px; 
  gap: 12px; 
  flex-wrap: wrap; 
}

.total-section { 
  text-align: right; 
  margin-top: 10px; 
  font-size: 15px; 
  font-weight: 700; 
}

.payment-section { 
  text-align: right; 
  margin-top: 10px; 
  font-size: 15px; 
}

.live-stock-info { 
  font-size: 0.8rem; 
  color: var(--success); 
  font-weight: bold; 
  margin-left: 5px; 
}

.big-menu-btn { 
  padding: 18px; 
  font-size: 1rem; 
  background: var(--bg); 
  color: var(--text-primary);
  border: 2px solid var(--border); 
  border-radius: var(--radius-md); 
  cursor: pointer; 
  font-weight: 700; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  gap: 10px; 
  transition: all var(--transition-fast);
}

.big-menu-btn:hover { 
  background: var(--primary); 
  color: white; 
  border-color: var(--primary); 
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.big-menu-btn i { 
  font-size: 2rem; 
}

/* --------------------------------------------------------------------------
   12. CHARTS SECTION
   -------------------------------------------------------------------------- */
.chart-section .card {
  align-items: stretch;
  min-height: 250px;
}

.chart-section canvas {
  max-height: 200px;
  width: 100% !important;
}

/* --------------------------------------------------------------------------
   13. ANIMATIONS & EFFECTS
   -------------------------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* --------------------------------------------------------------------------
   14. RESPONSIVE BREAKPOINTS
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .dashboard {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  body { 
    padding: 6px; 
  }

  .header { 
    padding: 15px 12px; 
    flex-direction: column; 
    align-items: stretch; 
    gap: 12px; 
    position: relative;
    top: 0;
  }

  .header-left { 
    text-align: center; 
    align-items: center; 
    justify-content: center;
  }

  .header-center {
    max-width: 100% !important;
    margin: 5px 0 !important;
  }

  .header-btn-group { 
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 8px; 
    width: 100%; 
  }

  .header-btn-group .btn { 
    font-size: 0.82rem; 
    padding: 10px 6px; 
    width: 100%; 
    justify-content: center; 
  }
  
  .dashboard { 
    grid-template-columns: repeat(2, 1fr); 
    gap: 10px; 
  }

  .card { 
    padding: 12px 8px; 
  }

  .card h3, .card h4 { 
    font-size: 0.8rem; 
  }

  .card .value { 
    font-size: 1.3rem; 
  }

  .modal-content { 
    padding: 16px 12px; 
    max-width: 98vw; 
  }
  
  .invoice-info-grid { 
    flex-direction: column; 
    gap: 10px; 
  }

  .invoice-info-grid > div { 
    text-align: left !important; 
    width: 100%; 
  }

  .invoice-info-grid input { 
    width: 100% !important; 
  }

  #adminEditInvoiceModal .modal-content > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {
  .dashboard { 
    grid-template-columns: repeat(1, 1fr); 
  }

  .header-btn-group { 
    grid-template-columns: repeat(2, 1fr); 
  }

  th, td { 
    padding: 8px 6px; 
    font-size: 0.82rem; 
  }

  .quick-action-panel .btn {
    flex: 1 1 100%;
  }
}

/* --------------------------------------------------------------------------
   15. PRINT STYLES
   -------------------------------------------------------------------------- */
@media print {
  body * { 
    visibility: hidden; 
  }

  .modal { 
    position: absolute; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
    background: white; 
    z-index: 9999; 
    padding: 0;
  }

  .modal-content, .modal-content * { 
    visibility: visible; 
  }

  .modal-content { 
    box-shadow: none; 
    margin: 0; 
    border: none; 
    padding: 0; 
    width: 100%; 
    max-width: 100%; 
  }

  .invoice-paper { 
    min-height: 290mm; 
    padding: 20px; 
    box-shadow: none;
  }

  .invoice-actions, .add-row-btn, .no-print, .close-btn { 
    display: none !important; 
  }

  .inv-item-type { 
    appearance: none; 
    border: none; 
    background: transparent; 
    font-weight: bold; 
  }

  #invCash, #invDiscount { 
    border: none !important; 
    padding: 0; 
    margin: 0; 
    text-align: right;
  }
}