/* =========================================================
   COLONIAS — Sistema de diseño "Frasco oscuro"
   Dark mode con acentos vibrantes, inspirado en perfumería.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  /* Base */
  --bg-base: #0f0c14;
  --bg-surface: #1a1522;
  --bg-surface-2: #221b2e;
  --border: #322940;
  --border-soft: #241d30;

  /* Texto */
  --text-primary: #f5efe6;
  --text-muted: #a89bb8;
  --text-faint: #6f6480;

  /* Acentos */
  --gold: #e8b75c;
  --gold-soft: rgba(232, 183, 92, 0.14);
  --violet: #a855f7;
  --violet-soft: rgba(168, 85, 247, 0.16);
  --pink: #f472b6;
  --pink-soft: rgba(244, 114, 182, 0.14);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.14);

  /* Tipografía */
  --font-display: 'Fraunces', serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Radios y sombras */
  --radius: 14px;
  --radius-sm: 8px;
  --shadow-glow: 0 0 40px -12px rgba(168, 85, 247, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, var(--violet-soft), transparent),
    radial-gradient(ellipse 700px 500px at 100% 10%, var(--pink-soft), transparent);
  background-repeat: no-repeat;
}

h1, h2, h3, .font-display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.mono, .stat-value, .price { font-family: var(--font-mono); }

a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-soft);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.brand {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--pink));
  box-shadow: 0 0 12px var(--gold);
}

.nav-group { display: flex; flex-direction: column; gap: 4px; }

.nav-link {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s ease, color .15s ease;
}

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

.nav-link.active {
  background: var(--violet-soft);
  color: var(--text-primary);
  border: 1px solid rgba(168,85,247,0.35);
}

.nav-icon { width: 8px; height: 8px; border-radius: 2px; background: currentColor; opacity: .6; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--text-faint);
}

.main { padding: 32px 40px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.topbar h1 { font-size: 26px; }
.topbar .subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.socio-badge {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13.5px;
}
.mobile-logout { display: none; }

.socio-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--pink));
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform .1s ease, filter .15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), #d99a3c);
  color: #211505;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }

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

/* ---------- Grid & cards ---------- */
.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 2fr 1fr; }

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
}

.stat-card { display: flex; flex-direction: column; gap: 10px; }
.stat-label { color: var(--text-muted); font-size: 13px; font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 600; }
.stat-delta { font-size: 12.5px; font-weight: 600; width: fit-content; padding: 3px 8px; border-radius: 999px; }
.stat-delta.up { background: var(--green-soft); color: var(--green); }
.stat-delta.down { background: var(--red-soft); color: var(--red); }

.card-title {
  font-family: var(--font-display);
  font-size: 17px;
  margin-bottom: 16px;
}
.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-title-row .card-title { margin-bottom: 0; }
.card-lead {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: -8px 0 14px;
  line-height: 1.5;
}
.row-subtext {
  color: var(--text-faint);
  font-size: 12px;
  margin-top: 2px;
  font-weight: 400;
  white-space: normal;
}
.row-edit-link {
  color: var(--violet);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.row-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.row-actions-cell {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  white-space: normal !important;
}
.row-remove-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-body);
  color: var(--red);
  cursor: pointer;
}
.row-remove-btn:hover { text-decoration: underline; }
.field-hint {
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.4;
  margin-top: -2px;
}
.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.checkbox-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  padding: 5px 0;
  font-weight: 400;
  color: var(--text-primary);
}
.checkbox-list-item input { accent-color: var(--violet); width: 16px; height: 16px; flex-shrink: 0; }
.checkbox-inline {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
}
.checkbox-inline input { accent-color: var(--gold); width: 17px; height: 17px; }
.checkbox-inline label { font-size: 13.5px; color: var(--text-muted); font-weight: 500; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ---------- Elemento firma: medidor de frasco ---------- */
.bottle-gauge {
  display: flex;
  align-items: center;
  gap: 14px;
}

.bottle-gauge svg { flex-shrink: 0; }

.bottle-info { display: flex; flex-direction: column; gap: 2px; }
.bottle-name { font-size: 14.5px; font-weight: 600; }
.bottle-meta { font-size: 12.5px; color: var(--text-muted); }
.bottle-meta .mono { color: var(--text-primary); }

.fragrance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
}
.fragrance-row:last-child { border-bottom: none; }

/* ---------- Tabla ---------- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
  padding: 0 4px;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}
td { padding: 13px 0; border-bottom: 1px solid var(--border-soft); }
tr:last-child td { border-bottom: none; }

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.tag-ok { background: var(--green-soft); color: var(--green); }
.tag-low { background: var(--red-soft); color: var(--red); }
.tag-reserved { background: var(--violet-soft); color: var(--violet); }

/* ---------- Navegación inferior (móvil) ---------- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  background: rgba(26, 21, 34, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-soft);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.35);
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 12px;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  transition: color .15s ease, background .15s ease;
}
.bottom-nav-icon {
  display: flex;
  width: 22px; height: 22px;
}
.bottom-nav-icon svg { width: 100%; height: 100%; }
.bottom-nav a.active {
  color: var(--gold);
  background: var(--gold-soft);
}

/* ---------- Botón de acciones rápidas (FAB, móvil) ---------- */
.fab-toggle { display: none; }
.fab-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 3, 8, 0.55);
  z-index: 60;
}
.fab-wrap {
  display: none;
  position: fixed;
  right: 18px;
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 65;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}
.fab-btn {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--pink));
  color: #211505;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px -6px rgba(232, 183, 92, 0.55);
  cursor: pointer;
  transition: transform .2s ease;
}
.fab-btn svg { width: 24px; height: 24px; }
.fab-toggle:checked ~ .fab-wrap .fab-btn { transform: rotate(45deg); }
.fab-toggle:checked ~ .fab-backdrop { display: block; }

.fab-menu {
  display: none;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}
.fab-toggle:checked ~ .fab-wrap .fab-menu { display: flex; }

.fab-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 9px 16px 9px 10px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  white-space: nowrap;
}
.fab-menu-icon {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--violet-soft);
  color: var(--violet);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fab-menu-icon svg { width: 15px; height: 15px; }

@media (max-width: 640px) {
  .mobile-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    margin-left: 4px;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1;
  }
  .login-card { max-width: 100%; padding: 28px 22px; }
}

/* ================= Responsive tiers =================
   Desktop:  > 1024px  — sidebar completo, grid-4 a 4 columnas
   Tablet:   641–1024px — sidebar más angosto, grid-4 a 2 columnas
   Móvil:    <= 640px   — barra inferior, todo en 1 columna
   ======================================================= */

/* ---- Tablet ---- */
@media (max-width: 1024px) {
  .sidebar { width: auto; padding: 24px 14px; }
  .brand { font-size: 19px; }
  .nav-link { font-size: 13.5px; padding: 10px 12px; }
  .main { padding: 26px 24px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .topbar h1 { font-size: 23px; }
  .card { padding: 18px; }
}

/* ---- Móvil ---- */
@media (max-width: 640px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .fab-wrap { display: flex; }
  .main { padding: 18px 14px 88px; }
  .grid-4, .grid-2 { grid-template-columns: 1fr; }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .topbar h1 { font-size: 20px; }
  .topbar .subtitle { font-size: 13px; }
  .socio-badge { align-self: stretch; justify-content: center; font-size: 12.5px; }

  .card { padding: 15px; }
  .card-title { font-size: 15.5px; }
  .card-title-row { flex-wrap: wrap; }

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

  /* Las tablas se convierten en tarjetas apiladas (etiqueta: valor) para que
     ninguna columna se apriete ni se superponga en pantallas angostas. */
  .table-scroll { overflow: visible; margin: 0; padding: 0; }

  table.responsive-table { border: none; }
  table.responsive-table thead { display: none; }
  table.responsive-table, table.responsive-table tbody,
  table.responsive-table tr, table.responsive-table td {
    display: block;
    width: 100%;
  }
  table.responsive-table tr {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  table.responsive-table tr:last-child { margin-bottom: 0; }
  table.responsive-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    text-align: right;
  }
  table.responsive-table td:last-child { border-bottom: none; }
  table.responsive-table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: left;
    flex-shrink: 0;
  }
  table.responsive-table td.cell-primary {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    padding-top: 2px;
  }
  table.responsive-table td.cell-primary::before { margin-bottom: 3px; }
  table.responsive-table td.cell-primary a { font-size: 14.5px; font-weight: 600; color: var(--text-primary); }
  table.responsive-table .row-subtext { margin-top: 3px; }
  table.responsive-table td.row-actions-cell {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 6px;
  }
  table.responsive-table td.row-actions-cell::before { margin-bottom: 2px; }

  .filter-pills { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .filter-pills a { flex-shrink: 0; font-size: 12.5px; }

  .stat-value { font-size: 22px; }
  .stat-label { font-size: 12px; }

  .btn { width: 100%; }
  .btn-sm { width: auto; }
  .fragrance-row form .btn { width: auto; }

  .bottom-nav a { font-size: 10.5px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}

@media (max-width: 420px) {
  .bottle-gauge svg { width: 28px; height: 44px; }
  .brand { font-size: 20px; }
}

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.form-field.full { grid-column: 1 / -1; }

.input {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  width: 100%;
}
.input:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-soft);
}

.section-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.section-tabs a {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
}
.section-tabs a.active { color: var(--text-primary); background: var(--violet-soft); border-color: rgba(168,85,247,0.35); }

.filter-pills { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.filter-pills a {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
}
.filter-pills a.active { color: #211505; background: var(--gold); border-color: var(--gold); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 34px 30px;
}
.login-card .brand { justify-content: center; margin-bottom: 6px; font-size: 24px; }
.login-card .subtitle { text-align: center; color: var(--text-muted); font-size: 13.5px; margin-bottom: 26px; }
