/* ============================================================
   Gold Bot Dashboard - Premium Dark Theme with Gold Accents
   ============================================================ */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a1f2e;
  --bg-card-hover: #222840;
  --bg-glass: rgba(26, 31, 46, 0.85);
  --bg-input: #0f1420;

  --gold-primary: #d4af37;
  --gold-light: #ffd700;
  --gold-dark: #b8920a;
  --gold-glow: rgba(212, 175, 55, 0.3);
  --gold-gradient: linear-gradient(135deg, #d4af37, #ffd700, #d4af37);

  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --yellow: #f59e0b;
  --yellow-dim: rgba(245, 158, 11, 0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.15);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border: rgba(255, 255, 255, 0.06);
  --border-gold: rgba(212, 175, 55, 0.2);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 4px 20px rgba(212, 175, 55, 0.15);

  --transition: 0.2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated grid background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(212, 175, 55, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(59, 130, 246, 0.03) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ============================================================
   Header
   ============================================================ */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(10, 14, 23, 0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-gold);
  box-shadow: var(--shadow-sm);
}

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

.logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 8px var(--gold-glow));
}

.logo h1 {
  font-size: 20px;
  font-weight: 800;
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.logo .subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.5px;
}

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

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-badge.running .status-dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 1.5s infinite;
}

.status-badge.stopped .status-dot {
  background: var(--red);
}

.status-badge.idle .status-dot {
  background: var(--yellow);
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(1.3);
  }
}

.clock {
  font-size: 14px;
  font-weight: 600;
  color: var(--gold-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

.header-right {
  display: flex;
  gap: 8px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--gold-gradient);
  color: #1a1000;
  box-shadow: var(--shadow-gold);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(212, 175, 55, 0.3);
}

.btn-danger {
  background: var(--red);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

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

.btn-outline:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--gold-primary);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-sm:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-full {
  width: 100%;
  justify-content: center;
  padding: 12px;
  margin-top: 12px;
}

/* ============================================================
   Stats Row
   ============================================================ */
.stats-row {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  overflow-x: auto;
}

.stat-card {
  flex: 1;
  min-width: 150px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.stat-card:hover {
  border-color: var(--border-gold);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  font-size: 24px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--bg-secondary);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================================
   Main Content Layout
   ============================================================ */
.main-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 16px;
  padding: 0 24px 24px;
  max-height: calc(100vh - 220px);
}

/* ============================================================
   Panel (generic card)
   ============================================================ */
.panel {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ============================================================
   Locations Grid
   ============================================================ */
.locations-panel {
  overflow-y: auto;
  max-height: calc(100vh - 240px);
}

.locations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  padding: 14px;
}

.location-card {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.location-card:hover {
  border-color: var(--gold-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.location-card.selected {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 1px var(--gold-primary), var(--shadow-gold);
}

.location-card.has-stock {
  border-color: var(--green);
}

.location-card.has-stock::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--green);
}

.location-card.no-stock::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--red);
}

.location-card .loc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.location-card .loc-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  flex: 1;
}

.location-card .loc-city {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.location-card .loc-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.location-card .loc-status .stock-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.loc-status .stock-dot.available {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.loc-status .stock-dot.unavailable {
  background: var(--red);
}

.loc-status .stock-dot.unknown {
  background: var(--text-muted);
}

.location-card .loc-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Closed boutique styling */
.location-card.boutique-closed {
  opacity: 0.45;
  border-color: var(--border);
}

.location-card.boutique-closed::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--text-muted);
}

.location-card.boutique-closed:hover {
  opacity: 0.65;
  border-color: var(--text-muted);
}

.loc-status .stock-dot.closed {
  background: var(--text-muted);
  opacity: 0.6;
}

/* Toggle switch on location card */
.loc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.loc-header .loc-name {
  cursor: pointer;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loc-toggle {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

.loc-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.loc-toggle .toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--border);
  border-radius: 34px;
  transition: background 0.25s;
}

.loc-toggle .toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  transition: transform 0.25s;
}

.loc-toggle input:checked+.toggle-slider {
  background: var(--green);
}

.loc-toggle input:checked+.toggle-slider::before {
  transform: translateX(14px);
}

/* Disabled location card */
.location-card.loc-disabled {
  opacity: 0.35;
  border-color: var(--border);
  filter: grayscale(0.6);
}

.location-card.loc-disabled::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--text-muted);
}

.location-card.loc-disabled:hover {
  opacity: 0.55;
  border-color: var(--text-muted);
}

.loc-status .stock-dot.disabled {
  background: var(--text-muted);
  opacity: 0.4;
}

/* Priority badge */
.priority-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 4px;
  font-weight: 600;
}

/* ============================================================
   Side Panels
   ============================================================ */
.side-panels {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 240px);
  overflow-y: auto;
}

/* Stock Detail */
.stock-detail {
  padding: 14px;
  max-height: 250px;
  overflow-y: auto;
}

.stock-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-size: 13px;
  transition: background var(--transition);
}

.stock-item:hover {
  background: var(--bg-card-hover);
}

.stock-item .product-name {
  font-weight: 500;
  color: var(--text-primary);
}

.stock-item .product-price {
  color: var(--text-secondary);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.stock-item .stock-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.stock-badge.available {
  background: var(--green-dim);
  color: var(--green);
}

.stock-badge.unavailable {
  background: var(--red-dim);
  color: var(--red);
}

/* Purchase History */
.purchase-list {
  padding: 10px;
  max-height: 200px;
  overflow-y: auto;
}

.purchase-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  margin-bottom: 6px;
  border-left: 3px solid var(--text-muted);
  transition: all var(--transition);
}

.purchase-item.success {
  border-left-color: var(--green);
}

.purchase-item.failed {
  border-left-color: var(--red);
}

.purchase-item.skipped {
  border-left-color: var(--yellow);
}

.purchase-item .purchase-location {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.purchase-item .purchase-time {
  font-size: 10px;
  color: var(--text-muted);
}

.purchase-item .purchase-status {
  font-size: 11px;
  margin-top: 4px;
}

/* Activity Log */
.log-panel {
  flex: 1;
  min-height: 200px;
}

.log-container {
  padding: 8px 12px;
  max-height: 300px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.6;
}

.log-entry {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  word-break: break-all;
}

.log-entry .log-time {
  color: var(--text-muted);
  margin-right: 6px;
}

.log-entry .log-level {
  font-weight: 700;
  margin-right: 6px;
  text-transform: uppercase;
  font-size: 10px;
}

.log-entry .log-level.info {
  color: var(--blue);
}

.log-entry .log-level.warn {
  color: var(--yellow);
}

.log-entry .log-level.error {
  color: var(--red);
}

.log-entry .log-level.debug {
  color: var(--text-muted);
}

.log-entry .log-msg {
  color: var(--text-secondary);
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

.empty-state.small {
  padding: 20px;
  font-size: 12px;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  width: 500px;
  max-width: 90vw;
  max-height: 85vh;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-gold);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
}

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

.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.btn-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.btn-close:hover {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

.modal-body {
  padding: 20px;
}

.settings-group {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.settings-group:last-child {
  border-bottom: none;
}

.settings-group h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--gold-primary);
}

.settings-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.5;
}

label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

textarea,
.input-field {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  transition: border-color var(--transition);
}

textarea:focus,
.input-field:focus {
  outline: none;
  border-color: var(--gold-primary);
}

/* Toggle Switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
}

.toggle-label input {
  display: none;
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--bg-input);
  border-radius: 12px;
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all var(--transition);
}

.toggle-label input:checked+.toggle-switch {
  background: var(--gold-primary);
  border-color: var(--gold-dark);
}

.toggle-label input:checked+.toggle-switch::after {
  left: 20px;
  background: white;
}

/* Product Checkboxes */
.product-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.product-checkboxes label {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.product-checkboxes label:has(input:checked) {
  background: rgba(212, 175, 55, 0.15);
  border-color: var(--gold-primary);
  color: var(--gold-light);
}

.product-checkboxes input {
  accent-color: var(--gold-primary);
  margin: 0;
}

.status-message {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.status-message.success {
  background: var(--green-dim);
  color: var(--green);
}

.status-message.error {
  background: var(--red-dim);
  color: var(--red);
}

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast.success {
  border-left: 3px solid var(--green);
}

.toast.error {
  border-left: 3px solid var(--red);
}

.toast.warning {
  border-left: 3px solid var(--yellow);
}

.toast.info {
  border-left: 3px solid var(--blue);
}

@keyframes slideIn {
  from {
    transform: translateX(100px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ============================================================
   Scrollbar Styling
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr;
    max-height: none;
  }

  .locations-panel {
    max-height: 400px;
  }

  .side-panels {
    max-height: none;
  }

  #app-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
  }

  .header-center {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .stats-row {
    padding: 12px 16px;
  }

  .locations-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .locations-grid {
    grid-template-columns: 1fr;
  }

  .stats-row {
    flex-wrap: wrap;
  }

  .stat-card {
    min-width: calc(50% - 8px);
    flex: none;
  }
}