/* ── eKitwi Tools — dark theme matching eKitwi Home, on top of dashboard.css ── */

[hidden] {
  display: none !important;
}

:root {
  --bg:           #0f0f13;
  --surface:      #17171d;
  --card:         #1c1c24;
  --nav:          #1a1a22;
  --accent:       rgb(135, 40, 190);
  --accent-hover: #4f0467;
  --accent-text:  #ffffff;
  --text:         #e5e5ef;
  --text-muted:   rgba(229, 229, 239, 0.55);
  --text-dim:     rgba(229, 229, 239, 0.35);
  --border:       rgba(255, 255, 255, 0.08);
  --font-heading: 'Montserrat', sans-serif;
  --nav-height:   68px;
}

.card, .card-form, .kpi-card, .crm-card {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28);
}

.panel-header h1,
.crm-modal-title,
.module-nav-title,
.tool-card-title {
  font-family: var(--font-heading);
}

/* ── Navbar ────────────────────────────────────────────────────────────── */
#main-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  background: rgba(15, 15, 19, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}
.nav-logo { height: 26px; width: auto; }
.brand-name {
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.nav-links {
  position: relative;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.nav-link {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.nav-link.nav-cta {
  background: var(--accent);
  color: #fff;
  margin-left: 0.3rem;
}
.nav-link.nav-cta:hover { background: var(--accent-hover); color: #fff; }

/* ── Menú del usuario (navbar): el email despliega "Cerrar sesión" ──────
   Mismo patrón que .nav-user/.nav-user-menu en eKitwi ERP. ─────────────── */
.nav-user {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  transition: background-color 0.15s, color 0.15s;
}
.nav-user:hover,
.nav-user[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.nav-user-caret {
  width: 13px;
  height: 13px;
  opacity: 0.7;
  transition: transform 0.18s;
}
.nav-user[aria-expanded="true"] .nav-user-caret { transform: rotate(180deg); }

.nav-user-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 190px;
  padding: 6px;
  background: var(--nav);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  z-index: 1001; /* sobre #main-nav (1000) */
}
.nav-user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.nav-user-menu-item:hover { background: rgba(255, 255, 255, 0.06); }
.nav-user-menu-item svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Menú "Herramientas": trigger en el navbar + panel flotante que
   reemplaza al viejo drawer (mismo patrón que #apps-trigger/#apps-list en
   eKitwi ERP): círculo chico siempre visible en el navbar, panel
   independiente que se despliega debajo. ─────────────────────────────── */
#apps-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.15s;
  flex-shrink: 0;
}
#apps-trigger:hover,
#apps-trigger[aria-expanded="true"] { background: rgba(255, 255, 255, 0.1); }
#apps-trigger svg { width: 20px; height: 20px; }

#apps-list {
  position: fixed;
  top: calc(var(--nav-height) + 10px);
  left: 16px;
  width: 300px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - var(--nav-height) - 26px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 0.9rem 1.2rem;
  background: var(--nav);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 20px;
  z-index: 999; /* bajo #modal-login (1200) */
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top left;
  pointer-events: none;
  transition: opacity 0.16s, transform 0.16s;
}
#apps-list.open { opacity: 1; transform: none; pointer-events: auto; }

@media (prefers-reduced-motion: reduce) {
  #apps-list { transition: none; }
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.sidebar-section-label {
  padding: 0 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.side-item svg { width: 18px; height: 18px; flex-shrink: 0; color: inherit; }

.side-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f5f5fa;
}

.side-item.active {
  background: rgba(135, 40, 190, 0.22);
  color: #d8b7ed;
}

.side-item-badge {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(74, 222, 128, 0.16);
  color: #4ade80;
}
.side-item-badge.badge-soon {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}

/* ── Main content ──────────────────────────────────────────────────────── */
.dash-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(var(--nav-height) + 2rem) 1.5rem 3rem;
}

@media (max-width: 768px) {
  .dash-main { padding: calc(var(--nav-height) + 1.2rem) 1rem 2rem; }
}

/* ── Form additions ────────────────────────────────────────────────────── */
.crm-label textarea {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  width: 100%;
  resize: vertical;
  transition: border-color 0.2s;
  font-family: inherit;
}
.crm-label textarea:focus { border-color: var(--accent); }

.crm-label-full { flex: 1 1 100% !important; min-width: 100% !important; }

.crm-label-check {
  display: flex;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  flex: 1;
  min-width: 130px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}
.crm-label-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

select option { background: var(--surface); color: var(--text); }

/* ── Module nav cards (Resumen) ───────────────────────────────────────── */
#tools-home { display: flex; flex-direction: column; gap: 24px; }

.module-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.module-nav-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 24px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, transform 0.2s;
}
.module-nav-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.module-nav-card.is-soon { opacity: 0.6; cursor: default; }
.module-nav-card.is-soon:hover { border-color: var(--border); transform: none; }

.module-nav-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(66, 8, 71, 0.14);
  border: 1px solid rgba(213, 73, 241, 0.22);
  color: #d8b7ed;
}
.module-nav-icon svg { width: 20px; height: 20px; }

.module-nav-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.module-nav-title { font-size: 1.02rem; font-weight: 700; color: var(--text); }
.module-nav-desc { font-size: 0.82rem; color: var(--text-muted); }

/* ── QR tool panels ────────────────────────────────────────────────────── */
.qr-badge-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }

.qr-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .qr-layout { grid-template-columns: 1fr; }
}

.qr-options-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.qr-options-row .field { flex: 1; min-width: 130px; }

.qr-color-field input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 3px;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}

.qr-preview-card {
  position: sticky;
  top: calc(var(--nav-height) + 16px);
  align-items: center;
  text-align: center;
}
.qr-canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 220px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 16px;
}
.qr-canvas-wrap canvas,
.qr-canvas-wrap img { max-width: 100%; height: auto; border-radius: 8px; }
.qr-canvas-empty { font-size: 0.85rem; color: var(--text-dim); }

.qr-preview-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}
.qr-preview-actions button { flex: 1; }

.qr-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.4;
}

/* ── Login modal (Freemium gate) ──────────────────────────────────────── */
#modal-login {
  z-index: 1200; /* above #apps-list (999) */
}

.form-error {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: #f87171;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
}

.identity-promo {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.identity-promo p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}
.identity-promo a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}
.identity-promo a:hover { text-decoration: underline; }

/* ── Coming soon panel ────────────────────────────────────────────────── */
.soon-card {
  align-items: flex-start;
  gap: 12px;
}
.soon-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(66, 8, 71, 0.14);
  border: 1px solid rgba(213, 73, 241, 0.22);
  color: #d8b7ed;
}
.soon-icon svg { width: 22px; height: 22px; }
