/* ==========================================================================
   TicketStats Mercadona - Soft Emerald & Pro Light/Dark Design System
   ========================================================================== */

:root {
  /* Brand Tokens - Mercadona Soft Emerald */
  --brand-primary: #10b981;
  --brand-primary-hover: #059669;
  --brand-primary-soft: #d1fae5;
  --brand-primary-text: #047857;
  --brand-primary-glow: rgba(16, 185, 129, 0.12);

  --brand-blue: #3b82f6;
  --brand-blue-soft: #dbeafe;
  --brand-blue-text: #1d4ed8;

  --brand-purple: #8b5cf6;
  --brand-purple-soft: #ede9fe;
  --brand-purple-text: #6d28d9;

  --brand-amber: #f59e0b;
  --brand-amber-soft: #fef3c7;
  --brand-amber-text: #b45309;

  --brand-danger: #ef4444;
  --brand-danger-soft: #fee2e2;
  --brand-danger-text: #b91c1c;

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme (Soft Emerald & Clean Slate) */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-hover: #e2e8f0;

  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-dim: #94a3b8;

  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);

  --dropzone-bg: #ecfdf5;
  --dropzone-border: #a7f3d0;
}

/* Dark Theme (Sleek Zinc & Emerald Glow) */
[data-theme="dark"] {
  --bg-primary: #09090b;
  --bg-secondary: #18181b;
  --bg-tertiary: #27272a;
  --bg-hover: #3f3f46;

  --border-subtle: #27272a;
  --border-strong: #3f3f46;

  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-dim: #71717a;

  --card-bg: #18181b;
  --card-border: #27272a;
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.4);

  --dropzone-bg: rgba(16, 185, 129, 0.05);
  --dropzone-border: rgba(16, 185, 129, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  transition: background-color var(--transition), color var(--transition);
}

/* Sidebar Layout */
.sidebar {
  width: 240px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: var(--transition);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  margin-bottom: 2rem;
  padding: 0 0.5rem;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background-color: var(--brand-primary-soft);
  color: var(--brand-primary-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

.nav-link.active {
  color: var(--brand-primary-text);
  background-color: var(--brand-primary-soft);
  font-weight: 600;
}

[data-theme="dark"] .nav-link.active {
  color: var(--brand-primary);
  background-color: rgba(16, 185, 129, 0.15);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Main Content Area */
.app-content {
  margin-left: 240px;
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1300px;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    width: 100%;
    height: 64px;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    padding: 0 0.5rem;
    border-right: none;
    border-top: 1px solid var(--border-subtle);
  }

  .brand, .sidebar-footer {
    display: none;
  }

  .nav-menu {
    flex-direction: row;
    width: 100%;
    justify-content: space-around;
  }

  .nav-link {
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.7rem;
    padding: 0.4rem 0.6rem;
  }

  .app-content {
    margin-left: 0;
    padding: 1.25rem 1rem 80px 1rem;
  }
}

/* Page Header & Title */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.page-title h1 {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.page-title p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

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

.btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
}

.btn-theme-toggle {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-theme-toggle:hover {
  background-color: var(--bg-hover);
}

/* Dropzone Upload Container */
.dropzone {
  border: 2px dashed var(--dropzone-border);
  border-radius: var(--radius-xl);
  background-color: var(--dropzone-bg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--brand-primary);
  background-color: var(--brand-primary-soft);
  transform: translateY(-2px);
}

.dropzone-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background-color: var(--brand-primary-soft);
  color: var(--brand-primary-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.dropzone h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.dropzone p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.kpi-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.85rem;
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.kpi-subtext {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
}

/* Cards & Containers */
.card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 2rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* SVG Chart Container */
.chart-container {
  height: 220px;
  width: 100%;
  position: relative;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

th {
  padding: 0.85rem 1rem;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.775rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-strong);
}

td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

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

tr.clickable {
  cursor: pointer;
  transition: background-color var(--transition);
}

tr.clickable:hover td {
  background-color: var(--bg-hover);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-green {
  background-color: var(--brand-primary-soft);
  color: var(--brand-primary-text);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-red {
  background-color: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-blue {
  background-color: var(--brand-blue-soft);
  color: var(--brand-blue-text);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 620px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: scale(0.96);
  transition: transform var(--transition);
}

.modal-backdrop.show .modal-dialog {
  transform: scale(1);
}

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

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.35rem;
  cursor: pointer;
}

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

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hidden {
  display: none !important;
}
