/* ============================================================
   ESTILOS COMPARTIDOS — PromoTracker
   ============================================================ */

:root {
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --primary-light: #dbeafe;
  --accent: #22c55e;
  --accent-dark: #16a34a;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --warning: #f59e0b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --transition: 0.15s ease;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- Tipografía ---- */
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.375rem; font-weight: 700; line-height: 1.3; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 0.9375rem; font-weight: 600; }
p { margin-bottom: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .text-sm { font-size: 0.8125rem; }
.text-muted { color: var(--gray-500); }
.text-center { text-align: center; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }

/* ---- Botones ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: var(--white); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: var(--white); text-decoration: none; }

.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); text-decoration: none; }

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

.btn-sm { padding: 0.3125rem 0.625rem; font-size: 0.8125rem; border-radius: 5px; }
.btn-block { display: flex; width: 100%; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.65em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}
.badge-gray { background: var(--gray-200); color: var(--gray-700); }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-brand { background: var(--primary-light); color: var(--primary-dark); }
.badge-cat { background: #f3e8ff; color: #7e22ce; }
.badge-familia-elite { background: #ede9fe; color: #6d28d9; border: 1px solid #c4b5fd; font-weight: 700; min-width: 1.5em; justify-content: center; }
.badge-familia-plus  { background: #fff7ed; color: #c2410c; border: 1px solid #fdba74; font-weight: 700; min-width: 1.5em; justify-content: center; }

/* ---- Variaciones ---- */
.var-up { color: var(--accent-dark); font-weight: 600; }
.var-down { color: var(--danger); font-weight: 600; }
.var-neutral { color: var(--gray-500); }

/* ---- Formularios ---- */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.25rem;
}
.form-label .required { color: var(--danger); }

.input, .select, .textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15);
}
.input::placeholder, .textarea::placeholder { color: var(--gray-400); }
.textarea { resize: vertical; min-height: 80px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }
.input-inline { padding: 0.25rem 0.5rem; border: 1.5px solid var(--gray-300); border-radius: 4px; font-size: 0.8125rem; width: 90px; }
.input-inline:focus { outline: none; border-color: var(--primary); }

.form-hint { font-size: 0.75rem; color: var(--gray-500); margin-top: 0.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ---- Modal ---- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(4px);
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  box-shadow: var(--shadow-lg);
  position: relative;
  margin: auto;
}
.modal-box-wide { max-width: 900px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
}
.modal-header h2 { font-size: 1.125rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--gray-500);
  padding: 0.25rem;
  border-radius: 4px;
  line-height: 1;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-800); }
.modal-body { padding: 1.5rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-200);
}

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--gray-900);
  color: var(--white);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: auto;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #15803d; }
.toast-error { background: #b91c1c; }
.toast-info { background: var(--primary); }
.toast-icon { font-size: 0.875rem; flex-shrink: 0; }

/* ---- Loader ---- */
#global-loader {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}
#global-loader.active { display: flex; }
.loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#global-loader p { font-size: 0.875rem; color: var(--gray-600); font-weight: 500; }

/* ---- Confirm overlay ---- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(17,24,39,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.confirm-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.confirm-box h3 { margin-bottom: 0.75rem; }
.confirm-box p { color: var(--gray-600); margin-bottom: 1.5rem; }
.confirm-btns { display: flex; gap: 0.75rem; justify-content: center; }

/* ---- Tabla ---- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.table th {
  background: var(--gray-50);
  padding: 0.625rem 0.875rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--gray-600);
  border-bottom: 1.5px solid var(--gray-200);
  white-space: nowrap;
}
.table td {
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.table tr:hover td { background: var(--gray-50); }
.table tr:last-child td { border-bottom: none; }

/* ---- Code ---- */
code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  background: var(--gray-100);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  color: var(--primary-dark);
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-500);
}
.empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state h3 { color: var(--gray-700); margin-bottom: 0.5rem; }

/* ---- Arte clickeable ---- */
.arte-clickable { cursor: zoom-in; }

/* ---- Lightbox ---- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: fadeIn 0.18s ease;
}
.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  cursor: default;
}
.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s;
  z-index: 10000;
}
.lightbox-close:hover { background: rgba(255,255,255,0.3); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
