/* CRM chat.kliavlin.com — dark theme matching landing */
:root {
  --bg-primary: #0a0a0f;
  --bg-card: #12121a;
  --bg-input: #1a1a25;
  --bg-hover: #1e1e2a;
  --border: #2a2a3a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 0.95rem;
}

/* Form */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input, textarea, select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea { resize: vertical; min-height: 120px; }

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

/* Honeypot */
.hp-field { position: absolute; left: -9999px; opacity: 0; height: 0; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* Response message */
.response {
  margin-top: 20px;
  padding: 16px;
  border-radius: var(--radius-sm);
  display: none;
  animation: fadeIn 0.3s ease;
}
.response.success { display: block; background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.3); color: var(--success); }
.response.error { display: block; background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--danger); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* Spinner */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ======== Admin styles ======== */
.admin-container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }

.stats-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 120px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.stat-card .num { font-size: 1.75rem; font-weight: 700; color: var(--accent); }
.stat-card .label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.filters select, .filters input {
  width: auto;
  min-width: 140px;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  background: var(--bg-input);
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:hover td { background: var(--bg-hover); }

.msg-preview {
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-new { background: rgba(99,102,241,0.15); color: var(--accent); }
.badge-answered { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-in_progress { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-closed { background: rgba(100,116,139,0.15); color: var(--text-muted); }
.badge-spam { background: rgba(239,68,68,0.15); color: var(--danger); }

.badge-price { background: rgba(99,102,241,0.15); color: var(--accent); }
.badge-order { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-consultation { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-support { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-other { background: rgba(100,116,139,0.15); color: var(--text-muted); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.modal h2 { margin-bottom: 16px; font-size: 1.25rem; }
.modal .messages-list { margin: 16px 0; }
.modal .msg { padding: 10px; margin: 6px 0; border-radius: var(--radius-sm); }
.modal .msg-in { background: var(--bg-input); }
.modal .msg-out { background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.2); }
.modal .msg-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* Auth screen */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-card {
  max-width: 360px;
  width: 100%;
}

/* Responsive */
@media (max-width: 640px) {
  .container { padding: 20px 16px; }
  .card { padding: 20px; }
  h1 { font-size: 1.4rem; }
  .stats-bar { flex-direction: column; }
  .filters { flex-direction: column; }
  .filters select, .filters input { width: 100%; }
}
