/* Samtale Admin Panel - Dark Theme */

:root {
  --bg-body: #0f1117;
  --bg-sidebar: #161922;
  --bg-card: #1c1f2e;
  --bg-input: #252836;
  --border: #2a2d3a;
  --brand: #00a884;
  --brand-dark: #008f6f;
  --text: #e4e6eb;
  --text-dim: #8b8d97;
  --text-heading: #ffffff;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --info: #3b82f6;
  --radius: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

html, body {
  height: 100%; width: 100%;
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { cursor: pointer; font-family: inherit; border: none; background: none; color: var(--text); }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }
h1, h2, h3 { color: var(--text-heading); }
.hidden { display: none !important; }

.btn-primary {
  background: var(--brand);
  color: white;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-primary:hover { background: var(--brand-dark); }

.input-field {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  color: var(--text);
  transition: border-color 0.2s;
}

.input-field:focus { border-color: var(--brand); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }

/* Toggle */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background: #333; border-radius: 24px; transition: 0.2s;
}
.toggle-slider::before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--brand); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Layout */
.admin-container { width: 100vw; height: 100vh; display: flex; }

/* Login */
.login-view {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f1117 0%, #1c1f2e 100%);
}

.login-wrapper { animation: fadeUp 0.5s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.login-box {
  background: var(--bg-card);
  width: 420px;
  border-radius: 16px;
  padding: 40px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-brand { text-align: center; margin-bottom: 30px; }
.login-brand .logo { font-size: 48px; color: var(--brand); margin-bottom: 12px; }
.login-brand h1 { font-size: 22px; margin-bottom: 6px; }
.login-brand p { color: var(--text-dim); font-size: 13px; }

.login-form button {
  width: 100%; margin-top: 8px; padding: 12px; font-size: 15px;
}

.auth-error {
  color: var(--danger); background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2);
  padding: 10px; border-radius: var(--radius); font-size: 13px; text-align: center; margin-bottom: 12px;
}

.loader {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%; border-top-color: #fff;
  animation: spin 1s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Admin View */
.admin-view { display: flex; width: 100%; height: 100%; }

/* Sidebar */
.admin-sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  flex-shrink: 0;
}

.admin-logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 700; color: var(--brand);
  padding: 0 12px; margin-bottom: 28px;
}

.admin-logo i { font-size: 24px; }

.admin-nav-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px; border-radius: var(--radius);
  color: var(--text-dim); font-size: 14px; font-weight: 500;
  transition: all 0.15s; margin-bottom: 4px;
}

.admin-nav-btn i { font-size: 20px; }
.admin-nav-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.admin-nav-btn.active { background: rgba(0,168,132,0.12); color: var(--brand); }

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

.admin-user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin-bottom: 8px;
}

.admin-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}

.admin-user-info strong { font-size: 13px; display: block; color: var(--text); }
.admin-user-info small { font-size: 11px; color: var(--text-dim); }

/* Content */
.admin-content {
  flex: 1; overflow-y: auto; padding: 32px;
  background: var(--bg-body);
}

.admin-page { display: none; }
.admin-page.active { display: block; }

.admin-page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 28px;
}

.admin-page-header h1 {
  font-size: 24px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
}

.admin-page-header p { color: var(--text-dim); font-size: 14px; margin-top: 4px; }

/* Metric Cards */
.metric-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  display: flex; align-items: center; gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }

.metric-icon {
  width: 48px; height: 48px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: white;
}

.c1 .metric-icon { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.c2 .metric-icon { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.c3 .metric-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
.c4 .metric-icon { background: linear-gradient(135deg, #10b981, #059669); }

.metric-value { font-size: 28px; font-weight: 800; display: block; color: var(--text-heading); }
.metric-label { font-size: 13px; color: var(--text-dim); }

/* Charts */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}

.chart-card h3 {
  font-size: 15px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px; color: var(--text);
}

.chart-card canvas { width: 100% !important; }

/* Admin Table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.admin-table th, .admin-table td { padding: 14px 16px; text-align: left; }

.admin-table th {
  background: rgba(255,255,255,0.03);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-dim); border-bottom: 1px solid var(--border);
}

.admin-table td { border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 14px; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  padding: 4px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 600; display: inline-block;
}

.badge-active { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-inactive { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-trial { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-role { background: rgba(59,130,246,0.15); color: var(--info); }

.table-actions { display: flex; gap: 6px; }
.table-actions button {
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; font-size: 16px;
}
.table-actions button:hover { background: rgba(255,255,255,0.08); }

/* Plans Grid */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.plan-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  transition: transform 0.2s;
}

.plan-card:hover { transform: translateY(-2px); }
.plan-card.highlighted { border-color: var(--brand); }
.plan-card h3 { font-size: 20px; margin-bottom: 4px; }
.plan-card .plan-price { font-size: 32px; font-weight: 800; margin: 16px 0; color: var(--brand); }
.plan-card .plan-price small { font-size: 14px; color: var(--text-dim); font-weight: 400; }
.plan-desc { color: var(--text-dim); font-size: 13px; margin-bottom: 16px; }

.plan-features { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.plan-features li {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text);
}
.plan-features li i { color: var(--brand); font-size: 16px; }

/* Config Section */
.config-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}

.config-section h3 { font-size: 16px; margin-bottom: 20px; }

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Responsive */
@media (max-width: 768px) {
  .admin-sidebar { display: none; }
  .metric-cards { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .plans-grid { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }
}
