/* ServiceVoice AI Portal — Main Stylesheet
   Brand: Dark bg (#0d0d0d), Orange accent (#f97316), Cream text (#f5f0e8)
   Font: Inter, system stack */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ─── CSS Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg-primary: #0d0d0d;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #222222;
  --bg-card: #1e1e1e;
  --border: #2a2a2a;
  --border-light: #333333;
  --text-primary: #f5f0e8;
  --text-secondary: #a8a098;
  --text-muted: #6b6560;
  --orange: #f97316;
  --orange-hover: #ea6c0a;
  --orange-dim: rgba(249, 115, 22, 0.12);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.12);
  --gray: #6b7280;
  --gray-dim: rgba(107, 114, 128, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --shadow: 0 1px 3px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.6);
  --radius: 8px;
  --radius-lg: 12px;
  --nav-width: 220px;
  --transition: 150ms ease;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

/* ─── Auth Pages ─────────────────────────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-card .brand {
  font-size: 22px;
  font-weight: 700;
  color: var(--orange);
  margin-bottom: 28px;
}

.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.auth-card .subtitle {
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.auth-card .error-msg {
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 20px;
}

.auth-card .success-msg {
  background: var(--green-dim);
  border: 1px solid rgba(34,197,94,0.3);
  color: #86efac;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 20px;
}

/* ─── Form Elements ──────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-dim);
}

input::placeholder { color: var(--text-muted); }

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

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23a8a098' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: none;
  letter-spacing: 0;
}
.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--orange);
  cursor: pointer;
}

/* Toggle */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}
.toggle-label { font-size: 14px; color: var(--text-primary); }
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border-light);
  border-radius: 24px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle input:checked + .toggle-track { background: var(--orange); }
.toggle-track::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-track::after { transform: translateX(20px); }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--orange);
  color: #fff;
  width: 100%;
  padding: 13px 20px;
  font-size: 15px;
}
.btn-primary:hover:not(:disabled) { background: var(--orange-hover); }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover { background: var(--border); }

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

.btn-danger { background: var(--red-dim); color: #fca5a5; border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }

/* ─── Portal Layout ──────────────────────────────────────────────────────────── */
.portal-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--nav-width);
  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;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--orange);
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-item.active { background: var(--orange-dim); color: var(--orange); }

.nav-item .nav-icon { font-size: 16px; flex-shrink: 0; }

.nav-item .premium-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  background: var(--orange-dim);
  color: var(--orange);
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.sidebar-user {
  padding: 10px 12px;
  margin-bottom: 4px;
}
.sidebar-user .user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.sidebar-user .user-email { font-size: 12px; color: var(--text-muted); }

/* ─── Main Content ───────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--nav-width);
  flex: 1;
  padding: 32px;
  max-width: 1200px;
}

.page-header {
  margin-bottom: 28px;
}
.page-header h1 { font-size: 1.5rem; }
.page-header p { color: var(--text-secondary); margin-top: 4px; font-size: 14px; }

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

/* ─── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-blue { background: var(--blue-dim); color: var(--blue); }
.badge-orange { background: var(--orange-dim); color: var(--orange); }
.badge-gray { background: var(--gray-dim); color: #9ca3af; }
.badge-red { background: var(--red-dim); color: #fca5a5; }

/* ─── Table ──────────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

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

thead th {
  background: var(--bg-secondary);
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

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

tbody td {
  padding: 13px 16px;
  font-size: 14px;
  color: var(--text-primary);
}

.td-muted { color: var(--text-secondary); }
.td-actions { display: flex; gap: 6px; align-items: center; }

/* ─── Filter Bar ─────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 20px;
}

.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 160px; }

/* ─── Pagination ─────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-top: 1px solid var(--border);
}
.pagination-info { font-size: 13px; color: var(--text-muted); }
.pagination-controls { display: flex; gap: 8px; }

/* ─── Call Detail ────────────────────────────────────────────────────────────── */
.call-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.call-summary-item .label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.call-summary-item .value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.transcript-block {
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  padding: 20px;
  max-height: 500px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text-secondary);
}

.speaker-alex { color: var(--orange); font-weight: 600; }
.speaker-caller { color: var(--text-primary); font-weight: 600; }

/* ─── Speech Bubble (onboarding preview) ────────────────────────────────────── */
.speech-bubble {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
  padding: 16px 20px;
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.6;
  position: relative;
  margin-top: 16px;
}
.speech-bubble::before {
  content: '🤖 Alex says:';
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

/* ─── Wizard Steps ───────────────────────────────────────────────────────────── */
.wizard-steps {
  display: flex;
  gap: 0;
  margin-bottom: 32px;
}
.wizard-step {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  transition: color var(--transition), border-color var(--transition);
}
.wizard-step.active { color: var(--orange); border-bottom-color: var(--orange); }
.wizard-step.done { color: var(--green); border-bottom-color: var(--green); }

.wizard-nav {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}
.wizard-nav .btn { flex: 1; }

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

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 200ms ease;
  max-width: 340px;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--orange); }

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

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

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  padding: 0;
  line-height: 1;
  margin-top: -2px;
}
.modal-close:hover { color: var(--text-primary); }

.modal-pro-icon { font-size: 40px; margin-bottom: 16px; }

/* ─── Status indicators ──────────────────────────────────────────────────────── */
.refresh-status {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.refresh-dot {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ─── Loading state ──────────────────────────────────────────────────────────── */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  gap: 12px;
  font-size: 14px;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-light);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ─── Back link ──────────────────────────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
  text-decoration: none;
}
.back-link:hover { color: var(--text-primary); text-decoration: none; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-brand { padding: 14px 16px; border-bottom: none; flex: 1; }
  .sidebar-nav {
    flex-direction: row;
    padding: 8px;
    width: 100%;
    border-top: 1px solid var(--border);
    overflow-x: auto;
    gap: 4px;
  }
  .nav-item { white-space: nowrap; padding: 8px 10px; }
  .nav-item .nav-label { display: none; }
  .sidebar-footer { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .portal-layout { flex-direction: column; }
  .filter-bar { flex-direction: column; }
  .wizard-step { font-size: 10px; }
  .modal { padding: 24px 20px; }
}
