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

/* ── Login screen ── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

#login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}

#login-brand {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 24px;
}

#login-card h2 {
  font-size: 1.4rem;
  margin-bottom: 24px;
}

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

#login-form label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 8px;
}

#login-form input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  width: 100%;
}
#login-form input:focus { outline: none; border-color: var(--accent); }

.password-wrap {
  position: relative;
}
.password-wrap input { padding-right: 60px; }
#toggle-pw {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 4px 6px;
}
#toggle-pw:hover { color: var(--text); }

#login-error {
  font-size: 0.82rem;
  color: var(--red);
  min-height: 1.2em;
  margin-top: 4px;
}

#login-form .btn-green {
  margin-top: 16px;
  width: 100%;
  flex: none;
}

:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --surface2: #22263a;
  --accent:   #6c63ff;
  --green:    #22c55e;
  --red:      #ef4444;
  --text:     #e2e8f0;
  --muted:    #64748b;
  --border:   #2d3452;
  --radius:   10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ── */
#sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 20px;
}

#brand {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

#user-name {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 2px;
}

#user-number {
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 8px;
  min-height: 1em;
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-logout:hover { color: var(--red); border-color: var(--red); }

#nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: var(--accent); color: #fff; }

#device-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.offline  { background: var(--muted); }
.dot.ready    { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.busy     { background: var(--red);   box-shadow: 0 0 6px var(--red); }

/* ── Main ── */
#main {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  position: relative;
}

.tab { display: none; }
.tab.active { display: block; }

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text);
}

/* ── Dialer ── */
#call-panel {
  max-width: 340px;
}

#dial-number {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.4rem;
  text-align: center;
  padding: 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  letter-spacing: 2px;
}
#dial-number:focus { outline: none; border-color: var(--accent); }

#dialpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.dp-key {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 16px 0;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  transition: background 0.1s;
}
.dp-key span { font-size: 0.6rem; color: var(--muted); margin-top: 3px; font-weight: 400; }
.dp-key:hover { background: var(--surface2); }
.dp-key:active { background: var(--accent); }

#call-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

#call-timer {
  text-align: center;
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
  color: var(--green);
  margin-bottom: 8px;
}

#call-status-msg {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2em;
}

/* ── Buttons ── */
.btn-green, .btn-red, .btn-secondary {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-green   { background: var(--green); color: #fff; }
.btn-red     { background: var(--red);   color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); flex: none; padding: 8px 16px; font-size: 0.85rem; }
.btn-green:hover, .btn-red:hover { opacity: 0.88; }
.btn-green:disabled, .btn-red:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-green:active, .btn-red:active { transform: scale(0.97); }

/* ── SMS compose ── */
#sms-compose {
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#sms-to {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.95rem;
}
#sms-to:focus { outline: none; border-color: var(--accent); }

#sms-body {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  resize: vertical;
  font-family: inherit;
}
#sms-body:focus { outline: none; border-color: var(--accent); }

#sms-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#sms-char-count { font-size: 0.75rem; color: var(--muted); }
#btn-send-sms { flex: none; padding: 10px 24px; }

#sms-status-msg {
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2em;
}

/* ── History lists ── */
.history-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.history-icon {
  font-size: 1.1rem;
  margin-top: 1px;
  flex-shrink: 0;
}

.history-body {
  flex: 1;
}

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.history-main {
  font-size: 0.9rem;
  font-weight: 600;
}

.history-time {
  font-size: 0.72rem;
  color: var(--muted);
}

.history-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 3px;
}

.badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
}
.badge-in  { background: #1e3a5f; color: #60a5fa; }
.badge-out { background: #1a3a2a; color: #4ade80; }

.btn-reply {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.btn-reply:hover { color: var(--accent); border-color: var(--accent); }

.recording-row { margin-top: 6px; display: flex; align-items: center; gap: 8px; }
.btn-play {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.btn-play:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.btn-play:disabled { opacity: 0.5; cursor: default; }
.recording-loading { font-size: 0.72rem; color: var(--muted); }

/* ── Incoming overlay ── */
#incoming-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

#incoming-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 40px;
  text-align: center;
  min-width: 280px;
}

#incoming-from {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text);
}

#incoming-card div {
  display: flex;
  gap: 16px;
  justify-content: center;
}

#incoming-card .btn-green,
#incoming-card .btn-red {
  flex: 1;
  max-width: 110px;
}

/* ── Utilities ── */
.hidden { display: none !important; }
