/* ============================================================================
 * MULTI-BOT TELEGRAM MINI APP & ADMIN DASHBOARD STYLES (public/styles.css)
 * ============================================================================ */

:root {
  --bg-main: #090d16;
  --bg-card: #111827;
  --bg-card-hover: #172033;
  --bg-elevated: #1e293b;
  --bg-input: #0b1120;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(99, 102, 241, 0.45);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.55);
}

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

body {
  background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.14), transparent 45%),
              radial-gradient(circle at bottom left, rgba(6, 182, 212, 0.1), transparent 45%),
              var(--bg-main);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 80px;
}

/* Header Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(9, 13, 22, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

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

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Badges & Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.pill-admin {
  background: rgba(99, 102, 241, 0.16);
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.4);
}

.pill-user {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.35);
}

.pill-proxy {
  background: rgba(6, 182, 212, 0.14);
  color: #67e8f9;
  border-color: rgba(6, 182, 212, 0.35);
}

/* Main Container */
.container {
  max-width: 1320px;
  margin: 20px auto;
  padding: 0 16px;
}

/* Panel Mode Switcher (User Panel vs Admin Panel) */
.mode-switcher-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.mode-switcher {
  display: inline-flex;
  background: var(--bg-card);
  padding: 5px;
  border-radius: 14px;
  border: 1px solid var(--border);
  gap: 6px;
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mode-btn:hover {
  color: var(--text-main);
}

.mode-btn.active {
  background: linear-gradient(135deg, var(--primary), #4338ca);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

/* Sub-navigation Tabs */
.subtabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.subtab-btn {
  border: 1px solid transparent;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.subtab-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.subtab-btn.active {
  background: rgba(99, 102, 241, 0.16);
  color: #c7d2fe;
  border-color: var(--border-strong);
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
}

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

/* Generic Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

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

.card-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Forms & Inputs */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.input,
.select,
.textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
}

.textarea {
  min-height: 84px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
}

.btn-success {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.38);
}

.btn-success:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.28);
}

.btn-warning {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text-main);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: #283548;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 7px;
}

/* Account Cards Grid */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 16px;
}

.acc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.acc-card:hover {
  border-color: rgba(99, 102, 241, 0.35);
}

.acc-card.alert-border {
  border-color: rgba(245, 158, 11, 0.65);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.2);
}

.acc-card.unauth-border {
  border-color: rgba(239, 68, 68, 0.65);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2);
}

.acc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

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

.acc-bot-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.acc-bot-name {
  font-weight: 700;
  font-size: 15px;
}

.acc-user-tag {
  font-size: 12px;
  color: var(--text-muted);
}

/* Status Badges */
.status-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.st-MINING,
.st-ACTIVE {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.st-RUNNING {
  background: rgba(6, 182, 212, 0.16);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.35);
}

.st-OTP_REQUIRED,
.st-HUMAN_PASS_REQUIRED {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.st-UNAUTHORIZED,
.st-ERROR {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.st-PAUSED,
.st-NOT_ADDED {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

/* Stats Box inside Account Card */
.acc-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: var(--bg-input);
  padding: 11px 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.metric-item-label {
  font-size: 11px;
  color: var(--text-muted);
}

.metric-item-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.acc-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  gap: 8px;
  flex-wrap: wrap;
}

/* Special Inline Box for Leaf OTP & Victor's humanPass */
.special-action-box {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.special-action-title {
  font-size: 12px;
  font-weight: 700;
  color: #fbbf24;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.inline-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Admin 5-Account Monitoring Matrix */
.monitor-slot-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
}

.monitor-bots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.monitor-bot-cell {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.monitor-bot-cell.cell-alert {
  border-color: rgba(239, 68, 68, 0.65);
  background: rgba(239, 68, 68, 0.06);
}

.monitor-bot-cell.cell-warn {
  border-color: rgba(245, 158, 11, 0.65);
  background: rgba(245, 158, 11, 0.06);
}

.monitor-bot-cell.cell-ok {
  border-color: rgba(16, 185, 129, 0.35);
}

/* Data Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

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

th,
td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-input);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Console Log Box */
.console-box {
  background: #050811;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  max-height: 400px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-line {
  display: flex;
  gap: 8px;
  line-height: 1.45;
  word-break: break-word;
}

.log-ts {
  color: var(--text-dim);
  flex-shrink: 0;
}

.log-scope {
  font-weight: 700;
  color: #38bdf8;
  flex-shrink: 0;
}

.log-level-success { color: #34d399; }
.log-level-warn { color: #fbbf24; }
.log-level-error { color: #f87171; }
.log-level-action { color: #c084fc; }

/* Modal Overlay */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 14, 0.78);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  padding: 22px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.75);
  max-height: 90vh;
  overflow-y: auto;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  max-width: 360px;
}

@media (max-width: 640px) {
  .accounts-grid {
    grid-template-columns: 1fr;
  }
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
}
