/* ═══════════════════════════════════════════════════════════════
   Twilio Call Center — Styles
   Premium dark theme with glassmorphism, fully responsive
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);

  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.3);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.3);
  --amber: #f59e0b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 50%;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);

  --transition: 0.2s ease;
  --font: 'Inter', -apple-system, sans-serif;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Animated gradient background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(16,185,129,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(239,68,68,0.04) 0%, transparent 50%);
  z-index: 0;
  pointer-events: none;
}

/* ── Screens ─────────────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; position: relative; z-index: 1; }
.screen.active { display: flex; }

/* ══════════════════════════════════════════════════════════════
   LOGIN SCREEN
   ══════════════════════════════════════════════════════════════ */
#login-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-container {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 36px;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.5s ease;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  font-size: 48px;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 20px var(--accent-glow));
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 6px;
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  transition: border var(--transition), box-shadow var(--transition);
  outline: none;
}

.input-group input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.error-message {
  margin-top: 16px;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 13px;
  text-align: center;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff;
  box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  box-shadow: 0 6px 25px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-full { width: 100%; padding: 14px; font-size: 15px; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
  font-size: 18px;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-glass-hover); }

.btn-sm { padding: 6px 10px; font-size: 13px; }

.btn-icon {
  background: transparent;
  color: var(--text-muted);
  padding: 6px;
  font-size: 16px;
  border-radius: var(--radius-full);
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-glass-hover); }

.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════════
   DASHBOARD
   ══════════════════════════════════════════════════════════════ */
#dashboard-screen {
  flex-direction: column;
}

/* ── Top Bar ─────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-logo { font-size: 22px; }
.topbar-left h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  animation: pulse 2s infinite;
}

.status-badge.ready .status-dot { background: var(--green); }
.status-badge.error .status-dot { background: var(--red); animation: none; }
.status-badge.busy .status-dot { background: var(--red); }

/* ── Main Layout ─────────────────────────────────────────────── */
.dashboard-main {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 24px;
  padding: 24px;
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ── Panel ───────────────────────────────────────────────────── */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.panel-header .panel-title { margin-bottom: 0; }

/* ── Phone Input ─────────────────────────────────────────────── */
.phone-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.phone-input {
  flex: 1;
  padding: 14px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.5px;
  outline: none;
  transition: border var(--transition), box-shadow var(--transition);
}
.phone-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.phone-input::placeholder { color: var(--text-muted); font-weight: 400; }

.btn-clear {
  font-size: 14px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
}

/* ── Dial Pad ────────────────────────────────────────────────── */
.dial-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.dial-key {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 8px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.dial-key:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(255,255,255,0.15);
  transform: scale(1.03);
}
.dial-key:active {
  transform: scale(0.97);
  background: rgba(99, 102, 241, 0.15);
}

.key-num {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}
.key-letters {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-top: 3px;
  min-height: 12px;
}

/* ── Call Button ─────────────────────────────────────────────── */
.btn-call {
  width: 100%;
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--green), #059669);
  color: #fff;
  box-shadow: 0 4px 20px var(--green-glow);
  transition: all var(--transition);
  outline: none;
}
.btn-call:hover {
  box-shadow: 0 6px 30px var(--green-glow);
  transform: translateY(-1px);
}
.btn-call:active { transform: scale(0.98); }
.btn-call:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.call-icon { font-size: 20px; }

/* ── Active Call ─────────────────────────────────────────────── */
.active-call {
  margin-top: 20px;
  padding: 20px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
  animation: fadeInUp 0.3s ease;
}

.call-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.call-to {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.call-timer {
  font-size: 18px;
  font-weight: 600;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.call-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 24px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font);
  color: var(--text-secondary);
  transition: all var(--transition);
  outline: none;
}
.btn-control:hover { background: var(--bg-glass-hover); color: var(--text-primary); }
.btn-control.active {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.ctrl-icon { font-size: 20px; }
.ctrl-label { font-size: 11px; font-weight: 500; }

.btn-hangup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 32px;
  background: linear-gradient(135deg, var(--red), #dc2626);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font);
  color: #fff;
  box-shadow: 0 4px 15px var(--red-glow);
  transition: all var(--transition);
  outline: none;
}
.btn-hangup:hover {
  box-shadow: 0 6px 25px var(--red-glow);
  transform: translateY(-1px);
}

/* ── Call History ─────────────────────────────────────────────── */
.call-history {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.history-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; display: block; }

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  cursor: pointer;
}
.history-item:hover { background: var(--bg-glass-hover); }
.history-item:last-child { border-bottom: none; }

.history-direction {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-size: 16px;
  flex-shrink: 0;
}
.history-direction.outbound {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent);
}
.history-direction.inbound {
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
}

.history-details {
  flex: 1;
  min-width: 0;
}

.history-number {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-status {
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
}
.history-status.completed {
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
}
.history-status.busy, .history-status.failed, .history-status.no-answer {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
}
.history-status.canceled, .history-status.ringing, .history-status.in-progress, .history-status.queued {
  background: rgba(245, 158, 11, 0.12);
  color: var(--amber);
}

.history-duration {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.history-redial {
  padding: 6px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition);
  color: var(--text-muted);
  outline: none;
  font-family: var(--font);
}
.history-redial:hover {
  background: var(--bg-glass-hover);
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.3);
}

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */

/* Tablet */
@media (max-width: 900px) {
  .dashboard-main {
    grid-template-columns: 1fr;
    max-width: 520px;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .login-container { padding: 36px 24px; }
  .topbar { padding: 10px 16px; }
  .topbar-left h2 { font-size: 16px; }
  .dashboard-main { padding: 16px; gap: 16px; }
  .panel { padding: 16px; }
  .dial-key { padding: 12px 6px; }
  .key-num { font-size: 20px; }
  .phone-input { font-size: 16px; padding: 12px 14px; }
  .history-item { padding: 10px 12px; gap: 10px; }
}

/* Very small phones */
@media (max-width: 360px) {
  .dial-pad { gap: 6px; }
  .dial-key { padding: 10px 4px; }
  .key-num { font-size: 18px; }
  .call-controls { gap: 8px; }
  .btn-control { padding: 10px 16px; }
  .btn-hangup { padding: 10px 24px; }
}
