/* ═══════════════════════════════════════════════════════
   INFLATION & WEIGHT CONTROL — STYLE.CSS
   Premium, Glassmorphic, Responsive Theme System
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f8fafc;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --accent: #ef4444;
  --accent-hover: #dc2626;
  --border-color: rgba(226, 232, 240, 0.8);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.8);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.05), 0 4px 6px -2px rgba(15, 23, 42, 0.02);
  --shadow-glow: 0 0 15px rgba(239, 68, 68, 0.2);
}

.dark-mode {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #0f172a;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #64748b;
  --accent: #ef4444;
  --accent-hover: #f87171;
  --border-color: rgba(255, 255, 255, 0.08);
  --glass-bg: rgba(30, 41, 59, 0.4);
  --glass-border: rgba(255, 255, 255, 0.08);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 15px rgba(239, 68, 68, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-tertiary) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background 0.3s, color 0.3s;
  overflow-x: hidden;
}

/* Header bar */
.app-header-bar {
  position: sticky;
  top: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 24px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: var(--glass-bg);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  transition: all 0.3s;
}

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

.header-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.header-btn:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-md);
}

.header-btn:active {
  transform: scale(0.95);
}

.admin-lock-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  padding: 8px 16px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.admin-lock-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.admin-lock-btn.unlocked {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #10b981;
}

/* App container */
.container {
  width: 100%;
  max-width: 1200px;
  padding: 30px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* Title block */
.title-block {
  text-align: center;
}

.title-icon {
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: white;
  margin: 0 auto 16px;
  box-shadow: var(--shadow-glow);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.title-block h1 {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.title-block p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Main card */
.main-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 24px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
}

/* Search and actions */
.search-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-wrapper {
  position: relative;
  flex-grow: 1;
  max-width: 400px;
}

.search-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Table styling */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 65vh;
  border-radius: 16px;
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

th, td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  text-align: center;
}

thead {
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 0 var(--border-color);
}

th {
  background: #f1f5f9 !important;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.dark-mode th {
  background: #1e293b !important;
}

tr:last-child td {
  border-bottom: none;
}

tr {
  transition: background 0.2s;
}

tr:hover {
  background: rgba(239, 68, 68, 0.02);
}

/* N/A Values styling */
.na-val {
  color: var(--text-tertiary) !important;
  font-style: italic;
  opacity: 0.7;
}

.sku-cell {
  font-weight: 500;
  color: var(--text-primary);
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
}

.action-btns {
  display: flex;
  gap: 8px;
}

.action-btn {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.edit-btn {
  color: var(--text-secondary);
  background: rgba(71, 85, 105, 0.05);
}

.edit-btn:hover {
  background: rgba(71, 85, 105, 0.15);
}

.del-btn {
  color: var(--accent);
  background: rgba(239, 68, 68, 0.05);
}

.del-btn:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* Modal overlays */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 1000;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-weight: 600;
  font-size: 1.1rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--accent);
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Form fields */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.form-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 10px;
  border-left: 3px solid var(--accent);
  padding-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Toast container */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #334155;
  color: white;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 9999;
}

#toast.active {
  opacity: 1;
}

.table-header-group {
  text-align: center;
  background: #e2e8f0 !important;
}

.dark-mode .table-header-group {
  background: #334155 !important;
}

thead tr:last-child th {
  border-bottom: 2.5px solid rgba(148, 163, 184, 0.45) !important;
}
.dark-mode thead tr:last-child th {
  border-bottom: 2.5px solid rgba(100, 116, 139, 0.55) !important;
}

.brand-col {
  width: 180px;
  min-width: 140px;
}
@media (max-width: 768px) {
  .brand-col {
    min-width: 155px; /* Ensures Lay's MAX fits on mobile */
  }
}

tr.row-selected {
  background: rgba(16, 185, 129, 0.12) !important;
}
.dark-mode tr.row-selected {
  background: rgba(16, 185, 129, 0.18) !important;
}

/* Responsive fixes */
@media (max-width: 768px) {
  .container {
    padding: 15px 10px 40px;
    gap: 20px;
  }
  .main-card {
    padding: 16px;
    border-radius: 16px;
  }
  th, td {
    padding: 10px 12px;
  }
}

/* Premium Filter Dropdown Styling */
.filter-wrapper {
  position: relative;
  min-width: 200px;
}
.filter-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  z-index: 2;
}
.filter-select {
  width: 100%;
  padding: 10px 34px 10px 38px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.3s;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  z-index: 1;
}
.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}
.filter-wrapper::after {
  content: '\f078';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  font-size: 0.8rem;
}

/* Vertical Column dividers */
tbody td:nth-child(3),
tbody td:nth-child(5),
tbody td:nth-child(8),
thead tr:first-child th:nth-child(3),
thead tr:first-child th:nth-child(4),
thead tr:first-child th:nth-child(5),
thead tr:nth-child(2) th:nth-child(2),
thead tr:nth-child(2) th:nth-child(5) {
  border-right: 2px solid rgba(148, 163, 184, 0.45) !important;
}

.dark-mode tbody td:nth-child(3),
.dark-mode tbody td:nth-child(5),
.dark-mode tbody td:nth-child(8),
.dark-mode thead tr:first-child th:nth-child(3),
.dark-mode thead tr:first-child th:nth-child(4),
.dark-mode thead tr:first-child th:nth-child(5),
.dark-mode thead tr:nth-child(2) th:nth-child(2),
.dark-mode thead tr:nth-child(2) th:nth-child(5) {
  border-right: 2px solid rgba(100, 116, 139, 0.45) !important;
}

/* SKU Cell Explicit Width & Left-Alignment */
.sku-cell {
  min-width: 220px;
  width: 280px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left !important;
}

/* Brand Horizontal boundary dividers */
.brand-boundary td {
  border-bottom: 2.5px solid rgba(148, 163, 184, 0.45) !important;
}
.dark-mode .brand-boundary td {
  border-bottom: 2.5px solid rgba(100, 116, 139, 0.55) !important;
}

/* ========================================
   شاشة تنبيه دوران الشاشة (وضع أفقي)
   ========================================= */
#rotation-alert-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  z-index: 999999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.dark-mode #rotation-alert-overlay {
  background: linear-gradient(135deg, #450a0a 0%, #110000 100%);
}
.rotation-alert-content {
  text-align: center;
  padding: 40px;
  max-width: 90%;
}
.rotation-icon-container {
  position: relative;
  margin: 0 auto 30px;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: phoneShake 1.5s ease-in-out infinite;
}
.rotation-icon-container .fa-mobile-alt {
  font-size: 80px;
  color: #ef4444;
}
.dark-mode .rotation-icon-container .fa-mobile-alt {
  color: #f87171;
}
@keyframes phoneShake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-20deg); }
  75% { transform: rotate(20deg); }
}
.rotation-alert-content h2 {
  font-size: 2rem;
  color: #991b1b;
  margin-bottom: 15px;
  font-weight: 700;
  font-family: "Poppins", sans-serif;
}
.dark-mode .rotation-alert-content h2 {
  color: #fee2e2;
}
.rotation-alert-content p {
  font-size: 1.2rem;
  color: #b91c1c;
  margin-bottom: 10px;
  font-family: "Poppins", sans-serif;
}
.dark-mode .rotation-alert-content p {
  color: #fca5a5;
}
.rotation-alert-content .rotation-sub-text {
  font-size: 1rem;
  color: #ef4444;
  font-style: italic;
  margin-top: 20px;
}
.dark-mode .rotation-alert-content .rotation-sub-text {
  color: #f87171;
}
@media screen and (orientation: landscape) and (max-height: 500px) {
  #rotation-alert-overlay {
    opacity: 1 !important;
    pointer-events: all !important;
  }
  .app-header-bar,
  .container {
    display: none !important;
  }
  body {
    overflow: hidden !important;
  }
}
