/* ============================================================
   app.css  — Estilos globales
   ============================================================ */

/* --- Variables --- */
:root {
  --green-wa:    #25D366;
  --green-dark:  #128C7E;
  --green-light: #DCF8C6;
  --bg:          #f4f6f8;
  --sidebar-bg:  #111827;
  --sidebar-w:   250px;
  --topbar-h:    56px;
  --white:       #ffffff;
  --text:        #1f2937;
  --text-muted:  #6b7280;
  --border:      #e5e7eb;
  --radius:      8px;
  --shadow:      0 1px 4px rgba(0,0,0,.08);
  --danger:      #ef4444;
  --warning:     #f59e0b;
  --info:        #3b82f6;
  --success:     #10b981;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--text); }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { cursor: pointer; border: none; background: none; }

/* --- Layout app --- */
.app-body {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* --- Topbar --- */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  z-index: 100;
}
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.sidebar-toggle { display: none; }

/* Accesos rápidos topbar */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.topbar-btn:hover { background: var(--bg); color: var(--text); }
.topbar-btn--active { color: var(--green-dark); background: #f0fdf4; }
.topbar-btn--logout:hover { color: var(--danger); }
.topbar-btn-label { display: none; }
.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

@media (min-width: 1024px) {
  .topbar-btn-label { display: inline; }
}

/* --- Main content --- */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 24px;
  flex: 1;
  min-height: calc(100vh - var(--topbar-h));
}

/* --- Cards --- */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: opacity .15s, background .15s;
}
.btn:hover { opacity: .88; }
.btn-primary   { background: var(--green-wa); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-sm        { padding: 5px 11px; font-size: 12px; }
.btn-icon      { padding: 7px; }

/* --- Forms --- */
.form-group      { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 5px; }
.form-group small  { display: block; color: var(--text-muted); margin-top: 4px; font-size: 12px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--white);
  outline: none;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--green-wa); }
textarea.form-control { resize: vertical; min-height: 90px; }
.input-wrap { position: relative; }
.input-wrap .form-control { padding-right: 40px; }
.input-wrap .toggle-pass {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted);
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: var(--bg); color: var(--text-muted); }

/* --- Alerts --- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
th { font-weight: 600; background: var(--bg); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* --- Tabs (para secciones internas) --- */
.tab-nav {
  display: flex;
  border-bottom: 2px solid var(--border);
  gap: 0;
  margin-bottom: 20px;
}
.tab-nav .tab-link {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab-nav .tab-link.active { color: var(--green-dark); border-color: var(--green-dark); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* --- Utilities --- */
.hidden { display: none !important; }
.flex    { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.mt-4   { margin-top: 16px; }
.mb-4   { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 12px; }
.font-bold  { font-weight: 700; }

/* --- Grid de stats (dashboard) --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); }
.stat-card .stat-icon  { font-size: 22px; }

/* --- Status dots --- */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.dot-connected    { background: var(--success); }
.dot-disconnected { background: var(--text-muted); }
.dot-error        { background: var(--danger); }
.dot-connecting   { background: var(--warning); animation: pulse 1.2s infinite; }
.dot-banned       { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; } 50% { opacity: .3; }
}

/* --- QR code container --- */
.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.qr-box img { width: 200px; height: 200px; }

/* --- Modal (componente global) --- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
}
.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 90%; max-width: 500px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h4 { font-size: 15px; font-weight: 600; }
.modal-close { font-size: 20px; line-height: 1; color: var(--text-muted); }
.modal-body  { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* --- Spinner --- */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--green-wa);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Responsive --- */
@media (max-width: 767px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-250px); }
  .sidebar.open { transform: translateX(0); }
  .topbar { left: 0; }
  .sidebar-toggle { display: flex; align-items: center; }
  .main-content { margin-left: 0; padding: 16px; }
}
