/* ═══════════════════════════════════════════════════════════════════════
 * BEATRIZ WEREBE — Luxury BI Design System
 * Premium jewelry brand operational dashboard
 * ═══════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Inter:wght@300;400;500;600&display=swap');

:root {
  /* ─── Color Palette ──────────────────────────────────────────────── */
  --bw-white:          #FFFFFF;
  --bw-ice:            #FAFAFA;
  --bw-cream:          #F5F3EF;
  --bw-gold:           #C6A97A;
  --bw-gold-light:     #D4BC94;
  --bw-gold-dark:      #A8915F;
  --bw-black:          #000000;
  --bw-charcoal:       #1A1A1A;
  --bw-graphite:       #2D2D2D;
  --bw-slate:          #6B6B6B;
  --bw-silver:         #9A9A9A;
  --bw-mist:           #E8E6E3;
  --bw-border:         #E5E3E0;
  --bw-border-light:   #F0EEEB;

  /* ─── Semantic Colors ────────────────────────────────────────────── */
  --bw-success:        #2D7D46;
  --bw-success-bg:     #F0F9F4;
  --bw-warning:        #C6A97A;
  --bw-warning-bg:     #FDF8F0;
  --bw-danger:         #9B2C2C;
  --bw-danger-bg:      #FDF2F2;
  --bw-info:           #4A6FA5;
  --bw-info-bg:        #F0F5FC;

  /* ─── Typography ─────────────────────────────────────────────────── */
  --font-display:      'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:         'SF Mono', 'Fira Code', 'Consolas', monospace;

  /* ─── Type Scale ─────────────────────────────────────────────────── */
  --text-4xl:          2.25rem;    /* 36px */
  --text-3xl:          1.875rem;   /* 30px */
  --text-2xl:          1.5rem;     /* 24px */
  --text-xl:           1.25rem;    /* 20px */
  --text-lg:           1.125rem;   /* 18px */
  --text-base:         1rem;       /* 16px */
  --text-sm:           0.875rem;   /* 14px */
  --text-xs:           0.75rem;    /* 12px */

  /* ─── Spacing ────────────────────────────────────────────────────── */
  --space-1:           0.25rem;    /* 4px */
  --space-2:           0.5rem;     /* 8px */
  --space-3:           0.75rem;    /* 12px */
  --space-4:           1rem;       /* 16px */
  --space-5:           1.25rem;    /* 20px */
  --space-6:           1.5rem;     /* 24px */
  --space-8:           2rem;       /* 32px */
  --space-10:          2.5rem;     /* 40px */
  --space-12:          3rem;       /* 48px */
  --space-16:          4rem;       /* 64px */

  /* ─── Border Radius ──────────────────────────────────────────────── */
  --radius-sm:         4px;
  --radius-md:         6px;
  --radius-lg:         8px;
  --radius-xl:         12px;

  /* ─── Shadows ────────────────────────────────────────────────────── */
  --shadow-xs:         0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm:         0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:         0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg:         0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-xl:         0 20px 25px -5px rgba(0, 0, 0, 0.06), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-gold:       0 4px 14px rgba(198, 169, 122, 0.25);

  /* ─── Transitions ────────────────────────────────────────────────── */
  --transition-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base:   200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:   300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* ─── Layout ─────────────────────────────────────────────────────── */
  --sidebar-width:     260px;
  --sidebar-collapsed: 72px;
  --header-height:     64px;
  --content-max:       1400px;
}

/* ═══════════════════════════════════════════════════════════════════════
 * BASE STYLES
 * ═══════════════════════════════════════════════════════════════════════ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.5;
  color: var(--bw-black);
  background-color: var(--bw-ice);
}

/* ═══════════════════════════════════════════════════════════════════════
 * TYPOGRAPHY UTILITIES
 * ═══════════════════════════════════════════════════════════════════════ */

.font-display {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.font-body {
  font-family: var(--font-body);
}

.text-4xl { font-size: var(--text-4xl); line-height: 1.1; }
.text-3xl { font-size: var(--text-3xl); line-height: 1.15; }
.text-2xl { font-size: var(--text-2xl); line-height: 1.2; }
.text-xl  { font-size: var(--text-xl);  line-height: 1.3; }
.text-lg  { font-size: var(--text-lg);  line-height: 1.4; }
.text-base { font-size: var(--text-base); line-height: 1.5; }
.text-sm  { font-size: var(--text-sm);  line-height: 1.5; }
.text-xs  { font-size: var(--text-xs);  line-height: 1.4; }

/* ═══════════════════════════════════════════════════════════════════════
 * COMPONENT STYLES
 * ═══════════════════════════════════════════════════════════════════════ */

/* ─── Buttons ──────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--bw-gold);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--bw-gold);
  color: var(--bw-white);
  border-color: var(--bw-gold);
}

.btn-primary:hover {
  background: var(--bw-gold-dark);
  border-color: var(--bw-gold-dark);
  box-shadow: var(--shadow-gold);
}

.btn-secondary {
  background: var(--bw-white);
  color: var(--bw-black);
  border-color: var(--bw-border);
}

.btn-secondary:hover {
  background: var(--bw-ice);
  border-color: var(--bw-silver);
}

.btn-ghost {
  background: transparent;
  color: var(--bw-slate);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bw-cream);
  color: var(--bw-black);
}

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

.btn-danger:hover {
  background: #822222;
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
}

.btn-icon {
  padding: var(--space-2);
  aspect-ratio: 1;
}

/* ─── Cards ────────────────────────────────────────────────────────── */

.card {
  background: var(--bw-white);
  border: 1px solid var(--bw-border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-elevated {
  box-shadow: var(--shadow-md);
}

.card-elevated:hover {
  box-shadow: var(--shadow-lg);
}

/* ─── KPI Cards ────────────────────────────────────────────────────── */

.kpi-card {
  background: var(--bw-white);
  border: 1px solid var(--bw-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--bw-gold-light);
}

.kpi-card .kpi-label {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  color: var(--bw-slate);
  margin-bottom: var(--space-2);
  font-weight: 500;
}

.kpi-card .kpi-value {
  font-family: var(--font-body);
  font-size: var(--text-3xl);
  font-weight: 600;
  color: var(--bw-black);
  letter-spacing: -0.02em;
}

.kpi-card .kpi-change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.kpi-change.positive {
  color: var(--bw-success);
  background: var(--bw-success-bg);
}

.kpi-change.negative {
  color: var(--bw-danger);
  background: var(--bw-danger-bg);
}

/* ─── Tables ───────────────────────────────────────────────────────── */

.table-container {
  background: var(--bw-white);
  border: 1px solid var(--bw-border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--bw-border-light);
}

.table-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--bw-black);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--bw-slate);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: var(--bw-ice);
  border-bottom: 1px solid var(--bw-border-light);
}

.table td {
  font-size: var(--text-sm);
  color: var(--bw-charcoal);
  padding: var(--space-4);
  border-bottom: 1px solid var(--bw-border-light);
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--bw-ice);
}

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

/* ─── Form Elements ────────────────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--bw-charcoal);
}

.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--bw-black);
  background: var(--bw-white);
  border: 1px solid var(--bw-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.form-input::placeholder {
  color: var(--bw-silver);
}

.form-input:focus {
  outline: none;
  border-color: var(--bw-gold);
  box-shadow: 0 0 0 3px rgba(198, 169, 122, 0.15);
}

.form-input:disabled {
  background: var(--bw-ice);
  color: var(--bw-slate);
  cursor: not-allowed;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B6B6B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-10);
}

/* ─── Sidebar ──────────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bw-white);
  border-right: 1px solid var(--bw-border-light);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width var(--transition-slow);
}

.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--bw-border-light);
}

.sidebar-brand-text {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--bw-black);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
}

.sidebar-section {
  margin-bottom: var(--space-6);
}

.sidebar-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--bw-silver);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  font-size: var(--text-sm);
  color: var(--bw-slate);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.sidebar-link:hover {
  background: var(--bw-cream);
  color: var(--bw-black);
}

.sidebar-link.active {
  background: var(--bw-cream);
  color: var(--bw-gold-dark);
  font-weight: 500;
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ─── Main Content ─────────────────────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: var(--space-8);
}

.page-header {
  margin-bottom: var(--space-8);
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 500;
  color: var(--bw-black);
  margin-bottom: var(--space-2);
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--bw-slate);
}

/* ─── Filter Bar ───────────────────────────────────────────────────── */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--bw-white);
  border: 1px solid var(--bw-border-light);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
}

.filter-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.filter-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--bw-slate);
  white-space: nowrap;
}

.filter-select {
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  border: 1px solid var(--bw-border);
  border-radius: var(--radius-md);
  background: var(--bw-white);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B6B' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.filter-select:focus {
  outline: none;
  border-color: var(--bw-gold);
}

/* ─── Badges ───────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-sm);
}

.badge-gold {
  background: var(--bw-warning-bg);
  color: var(--bw-gold-dark);
  border: 1px solid var(--bw-gold-light);
}

.badge-success {
  background: var(--bw-success-bg);
  color: var(--bw-success);
}

.badge-danger {
  background: var(--bw-danger-bg);
  color: var(--bw-danger);
}

.badge-neutral {
  background: var(--bw-ice);
  color: var(--bw-slate);
  border: 1px solid var(--bw-border);
}

/* ─── Skeleton Loading ─────────────────────────────────────────────── */

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bw-ice) 25%, var(--bw-mist) 50%, var(--bw-ice) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-2);
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: var(--space-3);
}

.skeleton-card {
  height: 120px;
}

.skeleton-chart {
  height: 200px;
}

/* ─── Tooltip ──────────────────────────────────────────────────────── */

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--bw-white);
  background: var(--bw-charcoal);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 50;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ─── Progress Bar ─────────────────────────────────────────────────── */

.progress {
  height: 6px;
  background: var(--bw-mist);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--bw-gold);
  border-radius: 3px;
  transition: width var(--transition-slow);
}

/* ─── Avatar ───────────────────────────────────────────────────────── */

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bw-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--bw-gold-dark);
}

/* ─── Table overflow wrapper ────────────────────────────────────────
 * Wrap a <table class="table"> in <div class="table-scroll"> when the table
 * has many columns. The wrapper keeps the panel/table-container's width
 * while the table scrolls horizontally on smaller viewports. The min-width
 * on .table inside the wrapper prevents the columns from being crushed
 * below a readable width. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.table-scroll .table {
  min-width: 720px;
}

/* ─── Modal / Drawer ───────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

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

.modal {
  background: var(--bw-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 560px;
  width: calc(100% - var(--space-8));
  max-height: calc(100vh - var(--space-16));
  overflow: auto;
  transform: translateY(20px);
  transition: transform var(--transition-base);
}

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

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

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
}

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-6);
  border-top: 1px solid var(--bw-border-light);
}

/* ─── Tabs ─────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--bw-border-light);
  margin-bottom: var(--space-6);
}

.tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--bw-slate);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--bw-black);
}

.tab.active {
  color: var(--bw-gold-dark);
  border-bottom-color: var(--bw-gold);
}

/* ─── Upload Zone ──────────────────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--bw-border);
  border-radius: var(--radius-lg);
  padding: var(--space-12) var(--space-8);
  text-align: center;
  background: var(--bw-ice);
  transition: all var(--transition-base);
  cursor: pointer;
}

.upload-zone:hover {
  border-color: var(--bw-gold);
  background: var(--bw-white);
}

.upload-zone.dragover {
  border-color: var(--bw-gold);
  background: var(--bw-warning-bg);
}

.upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  color: var(--bw-silver);
}

.upload-text {
  font-size: var(--text-sm);
  color: var(--bw-slate);
}

.upload-text strong {
  color: var(--bw-gold-dark);
}

/* ─── Charts Container ─────────────────────────────────────────────── */

.chart-card {
  background: var(--bw-white);
  border: 1px solid var(--bw-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.chart-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--bw-black);
}

/* ─── Image Thumbnail ──────────────────────────────────────────────── */

.product-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--bw-border-light);
  transition: transform var(--transition-fast);
  cursor: pointer;
}

.product-thumb:hover {
  transform: scale(1.5);
  box-shadow: var(--shadow-lg);
  z-index: 10;
  position: relative;
}

/* ═══════════════════════════════════════════════════════════════════════
 * RESPONSIVE
 * ═══════════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .sidebar {
    width: var(--sidebar-collapsed);
  }
  
  .sidebar-brand-text,
  .sidebar-section-title,
  .sidebar-link span {
    display: none;
  }
  
  .sidebar-link {
    justify-content: center;
    padding: var(--space-3);
  }
  
  .main-content {
    margin-left: var(--sidebar-collapsed);
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
    padding: var(--space-4);
  }
  
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .kpi-card .kpi-value {
    font-size: var(--text-2xl);
  }
}
