@import url('./tokens.css');

/* =============================================
   BASE
============================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* =============================================
   MOBILE FRAME (.phone)
   — En mobile: full screen
   — En desktop: desaparece, el layout usa .desk-*
============================================= */
.phone {
  width: 100%;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* =============================================
   DESKTOP LAYOUT (>= 768px)
   Sidebar fijo izquierda + contenido derecha
============================================= */
@media (min-width: 768px) {

  body {
    background: #F0F2F7;
  }

  /* El .phone pasa a ser el wrapper del panel desktop */
  .phone {
    min-height: 100vh;
    flex-direction: row;
    align-items: stretch;
  }

  /* ---- SIDEBAR ---- */
  .app-header {
    width: 240px;
    height: 100vh;
    position: fixed;
    top: 0; left: 0;
    overflow: visible;
    z-index: 100;
    flex-shrink: 0;
  }

  .app-header .grad {
    border-radius: 0;
  }

  /* Reemplazamos el toprow horizontal por un layout vertical */
  .toprow {
    position: static;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 0;
    height: 100vh;
    display: flex;
  }

  /* Logo / marca en el sidebar */
  .sidebar-brand {
    padding: 28px 24px 24px;
    border-bottom: 1px solid rgba(255,255,255,.12);
    width: 100%;
  }

  .sidebar-brand .brand-name {
    font-size: 22px;
    font-weight: 900;
    color: #fff;
    letter-spacing: .3px;
  }

  /* Ocultar botones de mobile header en desktop */
  .icon-btn.back-btn,
  .icon-btn.menu-btn {
    display: none;
  }

  .title {
    display: none;
  }

  /* Nav links del sidebar */
  .sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    gap: 4px;
    overflow-y: auto;
  }

  .sidebar-nav a,
  .sidebar-nav button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255,255,255,.82);
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, color .15s;
    width: 100%;
    text-align: left;
  }

  .sidebar-nav a:hover,
  .sidebar-nav button:hover {
    background: rgba(255,255,255,.12);
    color: #fff;
  }

  .sidebar-nav a.active {
    background: rgba(255,255,255,.18);
    color: #fff;
  }

  .sidebar-nav .nav-icon {
    width: 18px; height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
  }

  .sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,.1);
  }

  /* ---- CONTENIDO PRINCIPAL ---- */
  .screen,
  .dash,
  section.screen {
    margin-left: 240px;
    flex: 1;
    min-height: 100vh;
    padding: 32px 40px 60px !important;
    background: #F0F2F7;
    overflow-y: auto;
  }

  /* Ocultar CTA stack fixed en desktop */
  .cta-stack {
    position: static !important;
    background: transparent !important;
    padding: 24px 0 0 !important;
    animation: none !important;
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 12px !important;
  }

  .cta-btn, .btn {
    width: auto !important;
    max-width: none !important;
    padding: 12px 28px !important;
    font-size: 13px !important;
    box-shadow: 0 4px 14px rgba(11,18,32,.14) !important;
  }

  .cta-btn.secondary, .btn-secondary {
    box-shadow: none !important;
  }

  /* ---- CARDS en desktop: grid ---- */
  .list {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 0 !important;
  }

  .card {
    border-radius: 16px;
    padding: 20px !important;
    min-height: 88px;
  }

  /* ---- HOME desktop ---- */
  .home-top {
    padding-top: 0;
  }

  .home-logo { display: none; }

  .home-welcome {
    text-align: left;
    margin-top: 0;
  }

  .home-eyebrow {
    font-size: 11px;
  }

  .home-name {
    font-size: 32px;
    font-weight: 900;
  }

  /* ---- PAGE TITLE desktop ---- */
  .desk-page-title {
    font-size: 24px;
    font-weight: 800;
    color: #0B1220;
    margin: 0 0 24px;
  }

  /* ---- STATS GRID (admin) ---- */
  .stats-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  /* ---- FORMS desktop: max-width legible ---- */
  .form-wrap {
    max-width: 560px;
    padding: 0 !important;
  }

  /* ---- DASH desktop ---- */
  .dash-content {
    align-items: flex-start !important;
    text-align: left !important;
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 32px;
    padding: 0 !important;
  }

  .dash-logo {
    width: 90px !important;
    height: 90px !important;
    flex-shrink: 0;
  }

  .dash-group {
    max-width: 100% !important;
    flex: 1;
    min-width: 200px;
  }

  .dash-field {
    max-width: 100% !important;
  }

  .field-hint { text-align: left !important; }

  .footer-actions {
    background: transparent !important;
    flex-direction: row !important;
    flex-wrap: wrap;
    padding: 24px 0 0 !important;
    gap: 12px !important;
  }

}

/* =============================================
   HEADER APP (mobile)
============================================= */
.app-header {
  position: relative;
  height: 71px;
  padding-top: env(safe-area-inset-top, 0px);
  overflow: hidden;
  z-index: 10;
  flex-shrink: 0;
}
.app-header .grad {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--header1), var(--header2));
}
.toprow {
  position: absolute;
  left: 14px; right: 14px; top: 19px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 2;
}
.title {
  flex: 1;
  text-align: center;
  color: #fff;
  font-weight: 800;
  font-size: 21px;
  letter-spacing: 1px;
}
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.75);
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}
.icon {
  width: 18px; height: 18px;
  stroke: rgba(11,18,32,.7);
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* =============================================
   SCREEN
============================================= */
.screen {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 140px;
}

/* =============================================
   BOTONES
============================================= */
.btn {
  display: block;
  width: 100%;
  max-width: 330px;
  margin: 0 auto;
  border: none;
  border-radius: 999px;
  padding: 14px 16px;
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .7px;
  text-transform: uppercase;
  background: var(--btn);
  color: var(--btnText);
  box-shadow: 0 14px 28px rgba(11,18,32,.18);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: transform .15s;
}
.btn:active { transform: scale(.985); }
.btn-secondary {
  background: rgba(11,18,32,.08);
  color: rgba(11,18,32,.75);
  box-shadow: none;
}

/* =============================================
   CTA STACK (mobile)
============================================= */
.cta-stack {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  width: min(430px, 100%);
  margin: 0 auto;
  padding: 16px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  background: linear-gradient(to top, rgba(245,246,250,1) 65%, rgba(245,246,250,0));
  z-index: 60;
  animation: ctaSlideUp .35s cubic-bezier(.22,1,.36,1) both;
}
.cta-btn {
  width: 100%;
  max-width: 330px;
  margin: 0 auto;
  border: none;
  border-radius: 999px;
  padding: 14px 16px;
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .7px;
  text-transform: uppercase;
  background: var(--btn);
  color: var(--btnText);
  box-shadow: 0 14px 28px rgba(11,18,32,.18);
  cursor: pointer;
  transition: transform .15s;
}
.cta-btn.secondary {
  background: rgba(11,18,32,.08);
  color: rgba(11,18,32,.8);
  box-shadow: none;
}
.cta-btn:active { transform: scale(.985); }
@keyframes ctaSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* =============================================
   HOME
============================================= */
.home-top { padding-top: 24px; }
.home-logo { margin-top: 48px; text-align: center; }
.logo-gradient {
  font-weight: 900; font-size: 26px; letter-spacing: .4px;
  background: linear-gradient(90deg, #5b4bdb, #9b6cff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.home-welcome { margin-top: 32px; text-align: center; }
.home-eyebrow { font-size: 12px; letter-spacing: .18em; color: #9aa0a6; margin-bottom: 6px; }
.home-name { font-size: 28px; font-weight: 800; color: #3a3d42; margin: 0; }

/* =============================================
   LISTA / CARDS
============================================= */
.list { display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.card {
  background: #fff;
  border-radius: 20px;
  padding: 20px 18px;
  display: flex; align-items: stretch; justify-content: space-between;
  min-height: 96px;
  box-shadow: 0 10px 28px rgba(11,18,32,.07);
}
.card h3 { margin: 0 0 5px; font-size: 17px; font-weight: 800; color: #0B1220; }
.card .sub { margin: 0; font-size: 13px; font-weight: 500; color: rgba(11,18,32,.55); line-height: 1.35; }
.card-main { display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.card-meta { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; }
.card-link, .card-link:visited, .card-link:hover, .card-link:active { text-decoration: none; color: inherit; }
.card.is-inactive { opacity: .72; box-shadow: 0 6px 18px rgba(11,18,32,.05); }
.card.is-inactive h3 { color: rgba(11,18,32,.65); }
.card.is-inactive .sub { color: rgba(11,18,32,.4); }
@media (hover: hover) and (pointer: fine) {
  .card { transition: transform .22s cubic-bezier(.22,1,.36,1), box-shadow .22s; }
  .card:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(11,18,32,.11); }
}

/* =============================================
   PILLS
============================================= */
.pill { padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: rgba(11,18,32,.06); color: rgba(11,18,32,.55); }
.pill-active    { background: rgba(31,157,85,.12);  color: #1a8a4a; }
.pill-inactive  { background: rgba(11,18,32,.07);   color: rgba(11,18,32,.4); }
.pill-admin     { background: rgba(74,85,198,.12);  color: #4A55C6; }
.pill-productor { background: rgba(31,157,85,.1);   color: #1f9d55; }

/* =============================================
   DASHBOARD
============================================= */
.dash { flex: 1; display: flex; flex-direction: column; }
.dash-content { flex: 1; padding: 18px 18px 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.dash-logo {
  width: 110px; height: 110px; border-radius: 999px;
  background: #fff; border: 2px solid rgba(183,102,255,.18);
  box-shadow: 0 10px 25px rgba(11,18,32,.07); margin-top: 6px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative; cursor: pointer;
}
.logo-placeholder { font-weight: 900; color: rgba(11,18,32,.35); font-size: 13px; }
.logo-overlay {
  position: absolute; inset: 0; background: rgba(11,18,32,.45);
  color: #fff; font-size: 22px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: .18s; pointer-events: none;
}
.logo-loading { position: absolute; inset: 0; background: rgba(255,255,255,.8); display: flex; align-items: center; justify-content: center; }
.logo-loading.hidden { display: none; }
.dash-logo:hover .logo-overlay, .dash-logo:active .logo-overlay { opacity: 1; }
.dash-group { width: 100%; max-width: 330px; margin: 0 auto; }
.dash-field { width: 100%; max-width: 320px; padding: 12px 14px; border-radius: 16px; background: rgba(255,255,255,.7); border: 1px solid rgba(11,18,32,.08); box-shadow: 0 10px 22px rgba(11,18,32,.06); cursor: pointer; }
.dash-field-label { font-size: 16px; font-weight: 900; color: #282B34; }
.dash-field-value { font-size: 13px; font-weight: 800; color: rgba(11,18,32,.62); }
.dash-field-multiline { font-size: 13px; font-weight: 600; padding: 10px 20px; text-align: left; }
.dash-gap-1 { margin-top: 16px; }
.dash-gap-2 { margin-top: 14px; }
.dash-gap-3 { margin-top: 16px; }
.field-hint { margin-top: 2px; font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: rgba(74,85,198,.65); text-align: center; opacity: .3; pointer-events: none; transition: .15s; }
.dash-group:hover .field-hint, .dash-group:active .field-hint { opacity: 1; }
.dash-meta { margin-top: 21px; font-size: 12px; color: rgba(11,18,32,.45); text-align: center; }
.dash-meta b { font-weight: 700; color: rgba(11,18,32,.6); }
.footer-actions { margin-top: auto; padding: 24px 18px calc(32px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 14px; background: linear-gradient(180deg, rgba(247,248,250,0), rgba(247,248,250,1) 40%); }

/* =============================================
   EDITOR MODAL
============================================= */
.editor { position: fixed; inset: 0; background: rgba(11,18,32,.45); display: flex; align-items: center; justify-content: center; z-index: 9999; backdrop-filter: blur(6px); }
.editor.hidden { display: none; }
.editor-box { width: 90%; max-width: 340px; background: #fff; border-radius: 28px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.22); }
.editor, .editor * { font-family: 'Inter', -apple-system, sans-serif; }
.editor-logo { display: flex; flex-direction: column; gap: 16px; }
#logoInput { width: 100%; padding: 20px; background: #f4f6f9; border: 2px dashed rgba(11,18,32,.1); border-radius: 18px; font-size: 14px; font-weight: 600; color: #444; cursor: pointer; }
.editor-logo small { display: block; text-align: center; color: rgba(11,18,32,.5); font-size: 12px; line-height: 1.4; }
.editor-url { display: flex; align-items: center; gap: 4px; background: #f8f9fc; padding: 4px 14px; border-radius: 14px; border: 1px solid rgba(11,18,32,.1); }
.editor-domain { font-size: 14px; font-weight: 700; color: rgba(11,18,32,.4); }
#editorSlug { border: none !important; background: transparent !important; padding: 12px 0 !important; font-weight: 700; box-shadow: none !important; flex: 1; font-size: 14px; }
.editor-input, .editor-textarea { width: 100%; padding: 14px; border-radius: 14px; border: 1px solid rgba(11,18,32,.15); font-size: 15px; font-weight: 600; outline: none; font-family: inherit; color: #0B1220; }
.editor-textarea { resize: none; line-height: 1.4; }
.editor-textarea::placeholder, .editor-input::placeholder { color: rgba(11,18,32,.4); font-weight: 500; }
.editor-counter { margin-top: 5px; font-size: 11px; text-align: right; color: rgba(11,18,32,.4); }
.editor-actions { display: flex; gap: 12px; margin-top: 28px; }
#cancelEdit { flex: 1; background: #f1f3f7; color: #555; border-radius: 999px; border: none; padding: 14px; font-weight: 800; font-family: inherit; cursor: pointer; }
#saveEdit   { flex: 1.2; background: var(--btn); color: #fff; border-radius: 999px; border: none; padding: 14px; font-weight: 800; font-family: inherit; cursor: pointer; }

/* SPINNER */
.spinner { width: 24px; height: 24px; border: 3px solid rgba(74,85,198,.2); border-top-color: var(--btn); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* MISC */
.currency { font-size: 11px; font-weight: 700; letter-spacing: .4px; color: rgba(11,18,32,.38); text-transform: uppercase; }
