/* ── Wammmaxxa Theme ──
   Dark cyberpunk style inherited from the original WA dashboard.
*/

:root {
  --bg: #0a0a0f;
  --surface: #111118;
  --surface2: #16161f;
  --border: #1e1e2e;
  --accent: #00ff88;
  --accent2: #7c3aed;
  --warn: #f59e0b;
  --danger: #ef4444;
  --text: #e2e8f0;
  --muted: #4a5568;
  --blue: #3b82f6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 30px 30px;
  z-index: -1;
  pointer-events: none;
}

/* ── Auth Pages ── */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.auth-header h1 {
  font-family: 'Syne', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--accent);
}

.auth-header p {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

.auth-form { margin-bottom: 1rem; }

.auth-message {
  padding: 0.8rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  text-align: center;
}

.auth-success { background: rgba(0,255,136,0.1); color: var(--accent); }
.auth-error { background: rgba(239,68,68,0.1); color: var(--danger); }

.auth-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 1.5rem;
}

/* ── App Layout ── */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 10;
}

.sidebar-brand {
  padding: 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-icon { font-size: 1.5rem; }
.brand-text {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--accent);
}

.sidebar-menu {
  flex: 1;
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 1.2rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.menu-item:hover {
  color: var(--text);
  background: rgba(255,255,255,0.03);
}

.menu-item.active {
  color: var(--accent);
  background: rgba(0,255,136,0.05);
  border-left-color: var(--accent);
}

.menu-item .icon { font-size: 1.1rem; width: 24px; text-align: center; }
.menu-divider { height: 1px; background: var(--border); margin: 0.4rem 1rem; }

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

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.9rem;
  color: white;
}

.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 0.8rem; font-weight: 600; }
.user-role { font-size: 0.65rem; color: var(--muted); }

.logout-btn {
  display: block;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.15s;
}

.logout-btn:hover { color: var(--danger); border-color: var(--danger); }

/* ── Main Content ── */

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 1.5rem;
  max-width: calc(100vw - 240px);
}

.main-content.full-width {
  margin-left: 0;
  max-width: 100vw;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.subtitle { color: var(--muted); font-size: 0.85rem; margin-top: 0.3rem; }
.header-meta { color: var(--muted); font-size: 0.75rem; }
.header-actions { display: flex; gap: 0.5rem; }

/* ── Stats Grid ── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.15s;
}

.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.stat-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.75rem; color: var(--muted); margin-top: 0.3rem; }

/* ── Cards ── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h2 { font-size: 1rem; font-weight: 700; font-family: 'Syne', sans-serif; }
.card-body { padding: 1.2rem; }

/* ── Forms ── */

.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.form-row .form-group { flex: 1; }
.form-row .flex-grow { flex: 2; }

input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.7rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent2);
}

textarea { resize: vertical; min-height: 60px; }

.form-message {
  padding: 0.8rem;
  border-radius: 8px;
  margin-top: 0.8rem;
  font-size: 0.85rem;
}

.form-message.success { background: rgba(0,255,136,0.1); color: var(--accent); }
.form-message.error { background: rgba(239,68,68,0.1); color: var(--danger); }

.quick-send-form { max-width: 700px; }

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary { background: var(--accent2); color: white; }
.btn-primary:hover { background: #6d28d9; }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.7rem; }
.btn-blue { background: var(--blue); color: white; }
.btn-blue:hover { background: #2563eb; }
.btn-warn { background: var(--warn); color: #000; }
.btn-warn:hover { background: #d97706; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ── Tables ── */

.table-container { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.6rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

th {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.65rem;
}

tr:last-child td { border-bottom: none; }
tr:hover { background: rgba(255,255,255,0.01); }

.actions { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.msg-body { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { white-space: nowrap; font-size: 0.7rem; color: var(--muted); }

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Badges ── */

.badge {
  padding: 0.2rem 0.5rem;
  border-radius: 16px;
  font-size: 0.6rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: inline-block;
}

.badge-ok, .badge-ready, .badge-sent, .badge-completed, .badge-authenticated {
  background: rgba(0,255,136,0.1);
  color: var(--accent);
}

.badge-qr, .badge-pending, .badge-scheduled {
  background: rgba(245,158,11,0.1);
  color: var(--warn);
}

.badge-disconnected, .badge-failed, .badge-warn, .badge-auth_failure, .badge-not_ok {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
}

.badge-initializing, .badge-user {
  background: rgba(124,58,237,0.1);
  color: var(--accent2);
}

.badge-admin {
  background: rgba(255,215,0,0.1);
  color: gold;
}

.badge-stopped, .badge-sleeping {
  background: rgba(74,85,104,0.2);
  color: var(--muted);
}

/* ── Progress Bar ── */

.progress-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 150px;
}

.progress-fill {
  height: 6px;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s;
  min-width: 6px;
}

.progress-text { font-size: 0.65rem; color: var(--muted); white-space: nowrap; }

/* ── Logs ── */

.logs-body {
  max-height: 0;
  overflow-y: auto;
  transition: max-height 0.4s ease;
  padding: 0 1.2rem;
}

.logs-body.open {
  max-height: 400px;
  padding: 1rem 1.2rem;
}

#log-container { font-size: 0.7rem; }

.log-entry {
  padding: 0.3rem 0;
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.log-entry:last-child { border-bottom: none; }
.log-time { color: var(--muted); white-space: nowrap; min-width: 65px; }
.log-level { font-weight: bold; min-width: 45px; text-transform: uppercase; }
.log-msg { flex: 1; word-break: break-word; }
.log-error .log-level { color: var(--danger); }
.log-warn .log-level { color: var(--warn); }

/* ── Highlight ── */

.highlight {
  background: rgba(124,58,237,0.1);
  border: 1px solid var(--accent2);
  border-radius: 8px;
  padding: 1rem;
  margin: 0.5rem 0;
  font-size: 0.85rem;
}

.api-key-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem;
}

.api-key-display code {
  flex: 1;
  font-size: 0.75rem;
  word-break: break-all;
}

.api-key-text { font-size: 0.7rem !important; }

.webhook-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 0.5rem;
}

.webhook-item span { flex: 1; font-size: 0.8rem; word-break: break-all; }

/* ── Scrollbar ── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Responsive ── */

@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .brand-text,
  .sidebar .menu-item span:not(.icon),
  .sidebar-footer .user-info,
  .sidebar-footer .logout-btn { display: none; }
  .sidebar .menu-item { justify-content: center; padding: 0.7rem; }
  .sidebar .sidebar-footer { padding: 0.5rem; }
  .sidebar .user-badge { justify-content: center; }
  .main-content { margin-left: 60px; max-width: calc(100vw - 60px); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { flex-direction: column; }
}
