/* ═══════════════════════════════════════
   TELEPHONY — Design System
   Black & White Minimalism
   ═══════════════════════════════════════ */

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

:root {
  --bg:          #09090b;
  --bg-elevated: #111113;
  --bg-card:     #18181b;
  --bg-hover:    #27272a;
  --bg-active:   #3f3f46;

  --border:      #27272a;
  --border-hover:#3f3f46;

  --text:        #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted:  #71717a;

  --white:       #ffffff;
  --black:       #000000;

  --danger:      #ef4444;
  --danger-hover:#dc2626;
  --success:     #22c55e;
  --warning:     #f59e0b;

  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   14px;
  --radius-full: 9999px;

  --shadow:      0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-lg:   0 4px 12px rgba(0,0,0,0.5);

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  min-height: 100vh;
}

/* ─── Typography ─── */

h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 600; }

/* ─── Buttons ─── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  background: var(--bg-hover);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  outline: none;
}

.btn:hover {
  background: var(--bg-active);
  border-color: #52525b;
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text-secondary);
}

.btn-primary {
  background: var(--white);
  color: var(--black);
  border-color: var(--white);
}

.btn-primary:hover {
  background: #e4e4e7;
  border-color: #e4e4e7;
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
  border-color: var(--danger);
}

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

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

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

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius);
}

.btn-icon.sm {
  width: 32px;
  height: 32px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─── Inputs ─── */

.input {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--transition);
}

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

.input:focus {
  border-color: var(--text-secondary);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ─── Cards ─── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition);
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}

/* ─── Layout ─── */

.page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Header ─── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.header-device {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 0.9375rem;
}

.header-device .room-number {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.header-device .separator {
  color: var(--text-muted);
}

.header-device .phone-number {
  color: var(--text-secondary);
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

/* ─── Workspace (split-screen) ─── */

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  overflow: hidden;
}

.workspace-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.workspace-panel-left {
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--black);
}

.workspace-panel-right {
  padding: 24px;
  overflow-y: auto;
}

/* ─── Phone Screen ─── */

.phone-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 100%;
  padding: 16px;
}

.phone-canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: calc(100% - 60px);
}

.phone-canvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  background: #000;
}

.phone-nav {
  display: flex;
  gap: 24px;
}

.phone-nav-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 1.1rem;
}

.phone-nav-btn:hover {
  background: var(--bg-active);
  color: var(--text);
}

.phone-nav-btn:active {
  transform: scale(0.93);
}

/* ─── Audio Room ─── */

.audio-room {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.audio-room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.audio-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--danger); }
.status-dot.connecting {
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

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

.audio-controls {
  display: flex;
  gap: 10px;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-hover);
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--white);
  cursor: pointer;
  transition: transform var(--transition);
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* ─── Rooms List ─── */

.rooms-page {
  padding: 40px 20px;
  max-width: 900px;
  margin: 0 auto;
}

.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.room-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}

.room-card .room-num {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.room-card .room-phone {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.room-card .room-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: auto;
}

/* ─── Auth Pages ─── */

.auth-box {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.auth-box .logo {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 8px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-footer {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}

.auth-footer a:hover {
  color: var(--text);
}

.auth-error {
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 0.8125rem;
}

/* ─── Admin Panel ─── */

.admin-page {
  padding: 32px 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.admin-section {
  margin-bottom: 40px;
}

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

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

.admin-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 12px 14px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: var(--bg-elevated);
}

.token-display {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--transition);
}

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

/* ─── 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;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  animation: slideUp 0.2s ease;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Toast ─── */

#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}

.toast {
  padding: 12px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease;
  max-width: 320px;
}

.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }

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

/* ─── Placeholder / Empty State ─── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state-icon {
  font-size: 2rem;
  opacity: 0.5;
}

/* ─── Tabs (admin) ─── */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  margin-bottom: -1px;
}

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

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

/* ─── Search ─── */

.search-bar {
  position: relative;
  max-width: 300px;
}

.search-bar .input {
  padding-left: 36px;
}

.search-bar::before {
  content: '⌕';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

/* ─── Utility ─── */

.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
