/* ============================================================
   Alpha Disparo 2.0 — Global Dark Theme
   ============================================================ */

/* ── Variáveis ─────────────────────────────────────────────── */
:root {
  --bg-root:       #0b0b10;
  --bg-primary:    #0f0f16;
  --bg-secondary:  #15151f;
  --bg-card:       #1c1c28;
  --bg-input:      #12121a;
  --bg-hover:      #22222e;
  --border:        #2a2a3a;
  --border-light:  #33334a;

  --text-primary:   #e8eaf6;
  --text-secondary: #94a3b8;
  --text-muted:     #505870;

  --blue:    #3b82f6;
  --blue-h:  #2563eb;
  --green:   #22c55e;
  --green-h: #16a34a;
  --red:     #ef4444;
  --red-h:   #dc2626;
  --yellow:  #eab308;
  --purple:  #a855f7;
  --orange:  #f97316;
  --cyan:    #06b6d4;

  --sidebar-w: 240px;
  --topbar-h:  60px;
  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.3);

  --transition: .2s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-root);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-h); }

img { max-width: 100%; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   Layout: sidebar + main
   ============================================================ */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.3px;
}

.sidebar-logo .logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 8px;
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  text-decoration: none;
  position: relative;
}

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

.nav-item.active {
  background: rgba(59,130,246,.12);
  color: var(--blue);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--blue);
  border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-radius: 50%;
  display: flex;
  align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: 11px; color: var(--text-muted); }

.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  transition: color var(--transition);
}
.btn-logout:hover { color: var(--red); }

/* ── Main content ──────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Page content ──────────────────────────────────────────── */
.page-content {
  padding: 28px;
  flex: 1;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Stats cards ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(59,130,246,.15); }
.stat-icon.green  { background: rgba(34,197,94,.15); }
.stat-icon.red    { background: rgba(239,68,68,.15); }
.stat-icon.yellow { background: rgba(234,179,8,.15); }
.stat-icon.purple { background: rgba(168,85,247,.15); }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), opacity var(--transition);
  text-decoration: none;
  line-height: 1;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--blue);   color: #fff; }
.btn-primary:hover  { background: var(--blue-h); color: #fff; }
.btn-success   { background: var(--green);  color: #fff; }
.btn-success:hover  { background: var(--green-h); color: #fff; }
.btn-danger    { background: var(--red);    color: #fff; }
.btn-danger:hover   { background: var(--red-h); color: #fff; }
.btn-warning   { background: var(--yellow); color: #000; }
.btn-secondary { background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { appearance: none; cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 10px 14px;
  text-align: left;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 12px 14px;
  color: var(--text-secondary);
  vertical-align: middle;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.badge-online   { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-offline  { background: rgba(239,68,68,.15);  color: var(--red); }
.badge-connecting { background: rgba(234,179,8,.15); color: var(--yellow); }
.badge-qr_code  { background: rgba(168,85,247,.15); color: var(--purple); }
.badge-running  { background: rgba(59,130,246,.15);  color: var(--blue); }
.badge-paused   { background: rgba(234,179,8,.15);   color: var(--yellow); }
.badge-finished { background: rgba(34,197,94,.15);   color: var(--green); }
.badge-cancelled{ background: rgba(239,68,68,.15);   color: var(--red); }
.badge-draft    { background: rgba(100,116,139,.15); color: var(--text-muted); }
.badge-sent     { background: rgba(34,197,94,.15);   color: var(--green); }
.badge-failed   { background: rgba(239,68,68,.15);   color: var(--red); }
.badge-pending  { background: rgba(100,116,139,.15); color: var(--text-secondary); }
.badge-free     { background: rgba(100,116,139,.15); color: var(--text-muted); }
.badge-basic    { background: rgba(59,130,246,.15);  color: var(--blue); }
.badge-premium  { background: rgba(234,179,8,.15);   color: var(--yellow); }
.badge-admin    { background: rgba(168,85,247,.15);  color: var(--purple); }

/* ── Progress bar ──────────────────────────────────────────── */
.progress {
  background: var(--bg-input);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  transition: width .4s ease;
}
.progress-bar.success { background: linear-gradient(90deg, var(--green), var(--cyan)); }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  box-shadow: var(--shadow);
  animation: modalIn .2s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 20px; padding: 2px 6px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--red); }

.modal-header  { flex-shrink: 0; }
.modal-body    { padding: 24px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-footer  { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; }

/* ── Toast notifications ───────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: all;
  animation: toastIn .3s ease;
  max-width: 320px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error   { border-left: 3px solid var(--red); }
.toast.toast-info    { border-left: 3px solid var(--blue); }
.toast.toast-warning { border-left: 3px solid var(--yellow); }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-danger  { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.12);  border: 1px solid rgba(34,197,94,.3);  color: #86efac; }
.alert-info    { background: rgba(59,130,246,.12); border: 1px solid rgba(59,130,246,.3); color: #93c5fd; }
.alert-warning { background: rgba(234,179,8,.12);  border: 1px solid rgba(234,179,8,.3);  color: #fde047; }

/* ── Spinner ───────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }
.spinner-center { display: flex; justify-content: center; padding: 40px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── QR Code modal ─────────────────────────────────────────── */
.qr-wrap {
  text-align: center;
  padding: 16px;
}
.qr-wrap img {
  border-radius: var(--radius-sm);
  border: 3px solid var(--border-light);
  max-width: 240px;
}
.phone-code {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 6px;
  color: var(--text-primary);
  text-align: center;
  padding: 20px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  font-family: monospace;
}

/* ── Auth page ─────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-root);
  padding: 20px;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo .logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-radius: 14px;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 26px;
  margin-bottom: 12px;
}
.auth-logo h1 { font-size: 22px; font-weight: 800; color: var(--text-primary); }
.auth-logo p  { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  background: none;
  border-top: none; border-left: none; border-right: none;
}
.auth-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.auth-form { display: none; }
.auth-form.active { display: block; }

/* ── Misc ──────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.text-muted   { color: var(--text-muted); }
.text-success { color: var(--green); }
.text-danger  { color: var(--red); }
.text-warning { color: var(--yellow); }
.text-info    { color: var(--cyan); }
.text-primary-c { color: var(--blue); }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-3 { margin-top: 12px; }
.mb-3 { margin-bottom: 12px; }
.w-100 { width: 100%; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-title {
  font-size: 20px;
  font-weight: 700;
}
.section-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Responsive sidebar toggle ─────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
}

.mobile-menu-btn {
  display: none;
  background: none; border: none;
  color: var(--text-primary); cursor: pointer;
  font-size: 22px; padding: 4px;
}
@media (max-width: 900px) { .mobile-menu-btn { display: block; } }
