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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #242836;
  --border: #2e3344;
  --text: #e4e6f0;
  --text-muted: #8b8fa3;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --radius: 8px;
}

html,
body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.screen {
  height: 100%;
}

/* ── Login ─────────────────────────────────── */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 360px;
  text-align: center;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-card .subtitle {
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 14px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-form input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

#login-form input:focus {
  border-color: var(--accent);
}

#login-form button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

#login-form button:hover {
  background: var(--accent-hover);
}

.error {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
}

/* ── App shell ─────────────────────────────── */

#app-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

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

header h1 {
  font-size: 18px;
  font-weight: 700;
}

.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.online {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
}

.status-badge.offline {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
}

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

/* ── Tabs ──────────────────────────────────── */

.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ── Phone tab ─────────────────────────────── */

.phone-panel {
  max-width: 320px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.phone-panel input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  font-size: 18px;
  text-align: center;
  outline: none;
  letter-spacing: 1px;
}

.phone-panel input:focus {
  border-color: var(--accent);
}

.dialpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.dial-key {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 20px;
  font-weight: 500;
  padding: 14px;
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.dial-key small {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 2px;
  font-weight: 400;
}

.dial-key:hover {
  background: var(--surface-2);
}

.dial-key:active {
  background: var(--border);
}

.call-actions {
  display: flex;
  justify-content: center;
}

.btn-call {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 12px 48px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-call:hover {
  opacity: 0.9;
}

/* ── Active / Incoming call ────────────────── */

#active-call,
#incoming-call {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  z-index: 100;
}

.call-info {
  text-align: center;
}

.call-label {
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.call-remote {
  font-size: 28px;
  font-weight: 600;
}

.call-timer {
  font-size: 18px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
}

.call-controls {
  display: flex;
  gap: 16px;
}

.ctrl-btn {
  border: none;
  border-radius: 50px;
  padding: 12px 28px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 0.15s;
}

.ctrl-btn:hover {
  background: var(--border);
}

.ctrl-btn.hangup {
  background: var(--red);
  border-color: var(--red);
}

.ctrl-btn.hangup:hover {
  opacity: 0.9;
}

.ctrl-btn.accept {
  background: var(--green);
  border-color: var(--green);
}

.ctrl-btn.accept:hover {
  opacity: 0.9;
}

.ctrl-btn.muted {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #000;
}

/* ── SMS tab ───────────────────────────────── */

.sms-layout {
  display: flex;
  height: calc(100vh - 140px);
  gap: 1px;
  margin: -20px;
  background: var(--border);
}

.sms-sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.sms-compose-bar {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.sms-compose-bar input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.sms-compose-bar input:focus {
  border-color: var(--accent);
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
}

.conv-item {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.conv-item:hover {
  background: var(--surface);
}

.conv-item.active {
  background: var(--surface-2);
}

.conv-item .conv-number {
  font-weight: 600;
  font-size: 14px;
}

.conv-item .conv-preview {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.conv-item .conv-time {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
}

.sms-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.thread-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  background: var(--surface);
}

.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-bubble {
  max-width: 70%;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

.msg-bubble.outbound {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-bubble.inbound {
  align-self: flex-start;
  background: var(--surface-2);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.msg-bubble .msg-time {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
}

.sms-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.sms-input-bar input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.sms-input-bar input:focus {
  border-color: var(--accent);
}

.sms-input-bar button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.sms-input-bar button:hover {
  background: var(--accent-hover);
}

/* ── History tab ───────────────────────────── */

.history-panel {
  overflow-x: auto;
}

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

#history-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

#history-table td {
  padding: 10px 14px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

#history-table tbody tr:hover {
  background: var(--surface);
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 20px;
  font-size: 14px;
}
