/* ==========================================================================
   DUNAPP CLOUD — Consola de Administración
   Dark Glass Morphism · mismos tokens que el panel corporativo (backend-nube)
   ========================================================================== */

:root {
  /* Fondos oscuros translúcidos */
  --bg-body: #1a2332;
  --bg-surface: rgba(30, 42, 58, 0.80);
  --bg-surface-hover: rgba(38, 52, 72, 0.90);
  --bg-card: rgba(26, 38, 54, 0.75);
  --bg-card-header: rgba(20, 30, 45, 0.85);
  --bg-inset: rgba(15, 23, 35, 0.65);
  --bg-active: rgba(50, 65, 88, 0.95);

  /* Bordes de vidrio */
  --border-glass: 1px solid rgba(255, 255, 255, 0.10);
  --border-glass-light: 1px solid rgba(255, 255, 255, 0.16);
  --border-glass-active: 1px solid rgba(91, 155, 248, 0.45);

  /* Sombras */
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255,255,255,0.08);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.40);

  /* Colores de acento */
  --accent-blue: #5B9BF8;
  --accent-cyan: #4FC3F7;
  --accent-green: #4CAF88;
  --accent-orange: #F0A060;
  --accent-red: #E05C60;
  --accent-purple: #9B7BE8;
  --accent-yellow: #E5C07B;

  /* Tipografía */
  --text-primary: rgba(255, 255, 255, 0.94);
  --text-secondary: rgba(255, 255, 255, 0.58);
  --text-muted: rgba(255, 255, 255, 0.35);

  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --radius-pill: 50px;
  --radius-card: 18px;
  --radius-inner: 12px;
  --transition: all 0.22s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-system);
  min-height: 100vh;
  color: var(--text-primary);
  background: #1a2332;
  background-image:
    radial-gradient(ellipse at 0% 0%, rgba(60, 100, 180, 0.35) 0%, transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(30, 60, 100, 0.30) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 50%, rgba(20, 35, 60, 0.50) 0%, transparent 70%);
  background-attachment: fixed;
  overflow-x: hidden;
}

.hidden { display: none !important; }
.full-width { width: 100%; justify-content: center; margin-top: 12px; }
.muted { color: var(--text-secondary); font-size: 0.80rem; }
.mono { font-family: var(--font-mono); font-size: 0.76rem; }

/* --------------------------------------------------------------------------
   PANTALLAS CENTRADAS (carga / login / setup / pendiente)
   -------------------------------------------------------------------------- */
.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.spinner {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent-blue);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   HEADER DARK GLASS
   -------------------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(18, 28, 42, 0.85);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-bottom: var(--border-glass);
  box-shadow: 0 2px 20px rgba(0,0,0,0.40);
  padding: 14px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.header-brand { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; min-width: 0; }
.header-logo { height: 36px; object-fit: contain; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.35)); }

.brand-text h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-text p { font-size: 0.78rem; color: var(--text-secondary); font-weight: 400; }

.header-actions {
  display: flex; align-items: center; flex: 1 1 auto; flex-wrap: wrap;
  justify-content: flex-end; gap: 12px;
}
.header-actions > * { flex: 0 0 auto; }

.user-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  background: var(--bg-inset);
  border: var(--border-glass);
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  white-space: nowrap;
}

.badge-tag {
  background: rgba(91, 155, 248, 0.25);
  color: var(--accent-blue);
  font-weight: 700; font-size: 0.68rem;
  padding: 2px 8px; border-radius: var(--radius-pill);
}

/* --------------------------------------------------------------------------
   BOTONES
   -------------------------------------------------------------------------- */
.glass-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 18px;
  background: var(--bg-surface);
  border: var(--border-glass);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  font-size: 0.82rem; font-weight: 600; font-family: inherit;
  white-space: nowrap; cursor: pointer;
  box-shadow: var(--shadow-glass);
  backdrop-filter: blur(16px);
  transition: var(--transition);
  text-decoration: none;
}
.glass-btn:hover { background: var(--bg-surface-hover); border-color: rgba(255,255,255,0.22); transform: translateY(-1px); }
.glass-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.glass-btn-primary { background: rgba(91, 155, 248, 0.20); border-color: rgba(91, 155, 248, 0.40); color: #fff; }
.glass-btn-primary:hover { background: rgba(91, 155, 248, 0.35); border-color: rgba(91, 155, 248, 0.60); }

.glass-btn-danger:hover { background: rgba(224, 92, 96, 0.25); border-color: rgba(224, 92, 96, 0.45); color: var(--accent-red); }

.btn-sm {
  background: var(--bg-inset);
  border: var(--border-glass);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  padding: 5px 12px;
  font-size: 0.75rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: var(--transition);
  white-space: nowrap;
}
.btn-sm:hover { background: var(--bg-surface-hover); border-color: rgba(255,255,255,0.22); }
.btn-sm-danger:hover { background: rgba(224, 92, 96, 0.25); border-color: rgba(224, 92, 96, 0.45); color: var(--accent-red); }
.btn-sm-primary { background: rgba(91, 155, 248, 0.18); border-color: rgba(91, 155, 248, 0.35); color: var(--accent-blue); }
.btn-sm-primary:hover { background: var(--accent-blue); color: #fff; }

/* --------------------------------------------------------------------------
   LAYOUT PRINCIPAL (sidebar nav + contenido)
   -------------------------------------------------------------------------- */
.layout {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 28px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.sidebar-nav {
  position: sticky;
  top: 96px;
  background: var(--bg-card);
  border: var(--border-glass);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(20px);
  padding: 12px;
}

.nav-list { display: flex; flex-direction: column; gap: 6px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-inner);
  padding: 11px 14px;
  color: var(--text-secondary);
  font-size: 0.88rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: var(--transition);
}
.nav-item:hover { background: var(--bg-inset); color: var(--text-primary); }
.nav-item.active { background: rgba(91, 155, 248, 0.18); border-color: rgba(91, 155, 248, 0.45); color: #fff; }
.nav-item svg { flex-shrink: 0; }

.content-area { min-width: 0; display: flex; flex-direction: column; gap: 20px; }

/* --------------------------------------------------------------------------
   CABECERA DE PÁGINA
   -------------------------------------------------------------------------- */
.page-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
}
.page-head h2 { font-size: 1.3rem; font-weight: 700; }
.page-sub { font-size: 0.80rem; color: var(--text-secondary); margin-top: 2px; }

/* --------------------------------------------------------------------------
   SECCIONES Y TARJETAS GLASS
   -------------------------------------------------------------------------- */
.glass-section {
  background: var(--bg-card);
  border: var(--border-glass);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(20px);
  padding: 22px 24px;
}

.section-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 20px; padding-bottom: 12px;
  border-bottom: var(--border-glass);
}
.section-header h2 { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }

/* --------------------------------------------------------------------------
   TABLAS
   -------------------------------------------------------------------------- */
.table-responsive { overflow-x: auto; }

.custom-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.84rem; }
.custom-table th {
  padding: 12px 14px; font-size: 0.74rem; text-transform: uppercase;
  color: var(--text-secondary); font-weight: 600;
  border-bottom: var(--border-glass); letter-spacing: 0.04em; white-space: nowrap;
}
.custom-table td {
  padding: 13px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}
.custom-table tbody tr { transition: var(--transition); }
.custom-table tbody tr:hover { background: var(--bg-surface-hover); }
.custom-table td.cell-name { font-weight: 600; color: #fff; }

.acciones { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* --------------------------------------------------------------------------
   BADGES
   -------------------------------------------------------------------------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: var(--radius-pill);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-critico { background: rgba(224, 92, 96, 0.20); color: var(--accent-red);    border: 1px solid rgba(224, 92, 96, 0.35); }
.badge-alto    { background: rgba(240, 160, 96, 0.20); color: var(--accent-orange); border: 1px solid rgba(240, 160, 96, 0.35); }
.badge-medio   { background: rgba(229, 192, 123, 0.20); color: var(--accent-yellow); border: 1px solid rgba(229, 192, 123, 0.35); }
.badge-normal  { background: rgba(76, 175, 136, 0.20); color: var(--accent-green);  border: 1px solid rgba(76, 175, 136, 0.35); }
.badge-blue    { background: rgba(91, 155, 248, 0.20); color: var(--accent-blue);   border: 1px solid rgba(91, 155, 248, 0.35); }
.badge-purple  { background: rgba(155, 123, 232, 0.20); color: var(--accent-purple); border: 1px solid rgba(155, 123, 232, 0.35); }
.badge-muted   { background: var(--bg-inset); color: var(--text-secondary); border: var(--border-glass); }

/* Indicador de conexión de tienda */
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  box-shadow: 0 0 8px currentcolor; vertical-align: middle;
}
.status-online  { background: var(--accent-green); color: var(--accent-green); }
.status-offline { background: var(--text-muted);   color: var(--text-muted); }

/* --------------------------------------------------------------------------
   CHIP COPIABLE (UUID de tienda / organización)
   -------------------------------------------------------------------------- */
.chip-copy {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-inset);
  border: var(--border-glass);
  border-radius: 8px;
  padding: 4px 9px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  max-width: 100%;
}
.chip-copy:hover { border-color: rgba(91, 155, 248, 0.5); color: var(--text-primary); }
.chip-copy .chip-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-copy svg { flex-shrink: 0; opacity: 0.75; }

/* --------------------------------------------------------------------------
   FORMULARIOS
   -------------------------------------------------------------------------- */
.form-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.form-field label { font-size: 0.80rem; color: var(--text-secondary); font-weight: 600; }

.form-field input,
.form-field select,
.form-field textarea,
.glass-input,
.cam-row input {
  background: var(--bg-inset);
  border: var(--border-glass);
  border-radius: var(--radius-inner);
  padding: 11px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.90rem;
  outline: none;
  transition: var(--transition);
  width: 100%;
}
.form-field input:focus,
.form-field select:focus,
.glass-input:focus,
.cam-row input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(91, 155, 248, 0.20);
}
.form-field select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-opacity='0.6' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.form-field select option { background: #1e2a3a; color: #fff; }
.form-field select:disabled { opacity: 0.6; cursor: not-allowed; }

.form-hint { font-size: 0.74rem; color: var(--text-secondary); line-height: 1.5; margin-top: -4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.cam-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.cam-row { display: flex; gap: 8px; align-items: center; }
.cam-row input { flex: 1; }

/* --------------------------------------------------------------------------
   MODALES
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 15, 25, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-dialog {
  width: 100%; max-width: 620px;
  background: var(--bg-surface);
  border: var(--border-glass-light);
  border-radius: var(--radius-card);
  box-shadow: 0 16px 48px rgba(0,0,0,0.60);
  padding: 26px;
  position: relative;
  animation: modalScale 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes modalScale { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }

.modal-header-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px; padding-bottom: 12px;
  border-bottom: var(--border-glass);
}
.modal-header-row h3 { font-size: 1.15rem; font-weight: 700; }

.btn-close {
  background: var(--bg-inset); border: var(--border-glass);
  color: var(--text-secondary);
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--transition);
}
.btn-close:hover { color: #fff; background: var(--accent-red); }

.modal-body { max-height: 70vh; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   LOGIN / SETUP / PENDIENTE
   -------------------------------------------------------------------------- */
.login-dialog { max-width: 440px; }
.login-head { text-align: center; margin-bottom: 22px; }
.login-logo { height: 48px; display: block; margin: 0 auto 8px; }
.login-logo-white { height: 46px; display: block; margin: 0 auto 10px; filter: drop-shadow(0 4px 12px rgba(91,155,248,0.25)); }
.login-head h2 { font-size: 1.30rem; font-weight: 700; }
.login-sub { font-size: 0.82rem; color: var(--text-secondary); margin-top: 4px; }
.login-foot { font-size: 0.72rem; color: var(--text-muted); text-align: center; margin-top: 16px; line-height: 1.5; }

.btn-submit-login {
  width: 100%; padding: 12px;
  background: var(--accent-blue);
  border: none; border-radius: var(--radius-pill);
  color: #fff; font-weight: 700; font-size: 0.90rem; font-family: inherit;
  cursor: pointer; transition: var(--transition); margin-top: 6px;
}
.btn-submit-login:hover { background: #73ABFB; box-shadow: 0 4px 18px rgba(91, 155, 248, 0.45); }
.btn-submit-login:disabled { opacity: 0.6; cursor: not-allowed; }

.login-alert {
  background: rgba(224, 92, 96, 0.15);
  border: 1px solid rgba(224, 92, 96, 0.35);
  color: var(--accent-red);
  padding: 10px 14px; border-radius: var(--radius-inner);
  font-size: 0.80rem; margin-bottom: 16px;
}

.info-box {
  background: var(--bg-inset);
  border: var(--border-glass);
  border-radius: var(--radius-inner);
  padding: 16px; font-size: 0.85rem; line-height: 1.6;
  color: var(--text-secondary);
}
.info-box code {
  background: rgba(0,0,0,0.30); padding: 1px 6px; border-radius: 5px;
  font-family: var(--font-mono); font-size: 0.78rem; color: var(--accent-cyan);
}
.info-box-warn {
  border-color: rgba(229, 192, 123, 0.40);
  background: rgba(229, 192, 123, 0.10);
}
.info-box-warn code {
  background: rgba(0,0,0,0.35);
  color: var(--accent-yellow);
}
.setup-steps { margin: 10px 0 0 18px; display: flex; flex-direction: column; gap: 8px; }

/* --------------------------------------------------------------------------
   ESTADOS
   -------------------------------------------------------------------------- */
.error-box {
  background: rgba(224, 92, 96, 0.12);
  border: 1px solid rgba(224, 92, 96, 0.35);
  color: var(--accent-red);
  border-radius: var(--radius-inner);
  padding: 16px; font-size: 0.85rem;
}
.empty-state { text-align: center; color: var(--text-secondary); padding: 36px 16px; font-size: 0.85rem; }
.loading-inline { color: var(--text-secondary); padding: 28px; text-align: center; font-size: 0.85rem; }

/* --------------------------------------------------------------------------
   TOASTS
   -------------------------------------------------------------------------- */
.toast-root {
  position: fixed; right: 20px; bottom: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 400px; pointer-events: none;
}
.toast {
  background: var(--bg-surface);
  border: var(--border-glass-light);
  border-left: 4px solid var(--accent-blue);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-primary);
  box-shadow: var(--shadow-glass);
  backdrop-filter: blur(16px);
  font-size: 0.85rem; line-height: 1.45;
  opacity: 0; transform: translateX(24px);
  transition: var(--transition);
  pointer-events: auto;
  overflow-wrap: anywhere;
}
.toast-visible { opacity: 1; transform: translateX(0); }
.toast-ok { border-left-color: var(--accent-green); }
.toast-error { border-left-color: var(--accent-red); }
.toast-warn { border-left-color: var(--accent-orange); }

/* --------------------------------------------------------------------------
   RESPONSIVE
   -------------------------------------------------------------------------- */
.app-header, .app-header *, .layout, .layout *, .modal-backdrop, .modal-backdrop * { min-width: 0; }
.user-badge, .custom-table td { overflow-wrap: anywhere; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 200px minmax(0, 1fr); padding: 20px; gap: 18px; }
  .app-header { flex-direction: column; align-items: stretch; padding: 12px 18px; gap: 12px; }
  .header-actions { justify-content: flex-start; }
}

@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 16px; }

  .sidebar-nav { position: static; padding: 10px; }
  .nav-list {
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-item { width: auto; flex: 0 0 auto; }

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

@media (max-width: 640px) {
  .layout { padding: 14px; gap: 14px; }
  .app-header { padding: 10px 14px; }
  .brand-text p { display: none; }
  .brand-text h1 { font-size: 13px; }
  .header-logo { height: 30px; }

  .header-actions {
    width: 100%; max-width: 100%; flex-wrap: nowrap;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .header-actions::-webkit-scrollbar { display: none; }

  .glass-section { padding: 16px 14px; border-radius: 16px; }
  .custom-table { min-width: 640px; }
  .custom-table td, .custom-table th { padding: 11px 10px; }

  .glass-btn, .btn-sm, .form-field input, .form-field select { min-height: 40px; }
  select, input, textarea { font-size: 16px; }

  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-dialog {
    width: 100%; max-width: 100% !important;
    padding: 18px 16px; max-height: 92vh; overflow-y: auto;
    border-radius: 18px 18px 0 0;
  }

  .toast-root { left: 14px; right: 14px; bottom: 14px; max-width: none; }
}
