/* ═══════════════════════════════════════════════════════════════
   Yeastar Bridge — Global Styles
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg:       #1a1a2e;
  --surface:  #16213e;
  --surface2: #0f3460;
  --accent:   #e94560;
  --text:     #e0e0e0;
  --text-dim: #8888aa;
  --success:  #2ecc71;
  --warning:  #f39c12;
  --danger:   #e74c3c;
  --info:     #3498db;
  --radius:   8px;
  --font:     system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background:  var(--bg);
  color:       var(--text);
  min-height:  100vh;
  font-size:   14px;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  transition: opacity .15s, background .15s;
}
button:hover { opacity: .85; }
button:active { opacity: .7; }
button:disabled { opacity: .4; cursor: not-allowed; }

input, select, textarea {
  font-family: var(--font);
  font-size: 14px;
  background: var(--surface2);
  border: 1px solid #2a2a5a;
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}
select option { background: var(--surface); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }

/* ════════════════════════════════════════════════════════════════
   SOFTPHONE  (index.html)
   ════════════════════════════════════════════════════════════════ */

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

.phone-card {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

/* Status bar */
.phone-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface2);
  font-size: 12px;
  color: var(--text-dim);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
  margin-right: 6px;
}
.status-dot.registered  { background: var(--success); }
.status-dot.connecting  { background: var(--warning); animation: pulse 1s infinite; }
.status-dot.error       { background: var(--danger); }

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

/* Display */
.phone-display {
  padding: 24px 20px 16px;
  text-align: center;
}

.call-state {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .1em;
  min-height: 18px;
}

.number-input {
  font-size: 28px;
  font-weight: 300;
  letter-spacing: .05em;
  color: var(--text);
  min-height: 44px;
  word-break: break-all;
}

.call-timer {
  font-size: 12px;
  color: var(--text-dim);
  min-height: 18px;
  font-variant-numeric: tabular-nums;
}

/* Quality bar */
.quality-bar {
  display: flex;
  gap: 6px;
  padding: 0 20px 8px;
  font-size: 11px;
  color: var(--text-dim);
  justify-content: center;
}

.quality-pill {
  background: var(--surface2);
  border-radius: 12px;
  padding: 2px 8px;
}

/* Dial Pad */
.dialpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 10px 20px 20px;
}

.dialpad-key {
  background: var(--surface2);
  color: var(--text);
  border-radius: 50%;
  width: 68px;
  height: 68px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  transition: background .1s;
}
.dialpad-key sub {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: .1em;
}
.dialpad-key:hover { background: #1e2d5e; }
.dialpad-key:active { background: #0a1a3e; }

/* Action buttons */
.phone-actions {
  display: flex;
  justify-content: space-evenly;
  padding: 0 20px 24px;
  gap: 12px;
}

.btn-call {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.btn-hangup {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.btn-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  align-self: center;
}
.btn-icon.active { background: var(--accent); }

/* Incoming call overlay */
.incoming-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.incoming-overlay.visible { display: flex; }

.incoming-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  width: 300px;
  animation: slideUp .3s ease;
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity:0; }
  to   { transform: translateY(0);    opacity:1; }
}
.incoming-card h2 { font-size: 14px; color: var(--text-dim); margin-bottom: 8px; }
.incoming-number  { font-size: 28px; margin-bottom: 24px; }
.incoming-actions { display: flex; gap: 20px; justify-content: center; }

/* Recent calls */
.recents-section { padding: 0 16px 16px; }
.recents-section h3 { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing:.1em; padding: 8px 4px; }

.call-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid rgba(255,255,255,.05);
  cursor: pointer;
}
.call-item:hover { background: rgba(255,255,255,.03); }
.call-icon { font-size: 16px; width: 24px; text-align: center; }
.call-info { flex: 1; min-width: 0; }
.call-num   { font-size: 14px; }
.call-meta  { font-size: 11px; color: var(--text-dim); }
.call-dur     { font-size: 12px; color: var(--text-dim); }
.recents-empty { font-size: 12px; color: var(--text-dim); text-align: center; padding: 12px 4px; }

/* ════════════════════════════════════════════════════════════════
   ADMIN PANEL  (admin.html)
   ════════════════════════════════════════════════════════════════ */

.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .05em;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo span { color: var(--text-dim); font-size: 11px; display: block; font-weight: 400; }

.sidebar-nav { padding: 12px 8px; flex: 1; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-dim);
  margin-bottom: 2px;
  transition: background .15s, color .15s;
  font-size: 14px;
}
.sidebar-nav a:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.sidebar-nav a.active { background: var(--surface2); color: var(--text); }
.sidebar-nav a .nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 11px;
  color: var(--text-dim);
}

/* AMI status badge */
.ami-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--surface2);
}
.ami-badge.connected  { color: var(--success); }
.ami-badge.error      { color: var(--danger); }
.ami-badge.disconnected { color: var(--text-dim); }

/* Main content */
.main-content {
  margin-left: 220px;
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* Sections */
.section { display: none; }
.section.active { display: block; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-title { font-size: 20px; font-weight: 600; }

/* Dashboard cards */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px;
}
.card-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing:.1em; }
.card-value { font-size: 32px; font-weight: 700; margin: 6px 0 2px; }
.card-sub   { font-size: 12px; color: var(--text-dim); }
.card.accent { border-left: 3px solid var(--accent); }
.card.green  { border-left: 3px solid var(--success); }
.card.blue   { border-left: 3px solid var(--info); }
.card.yellow { border-left: 3px solid var(--warning); }

/* Tables */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--surface2);
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .07em;
  font-weight: 600;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid rgba(255,255,255,.05); transition: background .1s; }
tbody tr:hover { background: rgba(255,255,255,.03); }
tbody td { padding: 10px 14px; vertical-align: middle; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.badge-answered { background: rgba(46,204,113,.2); color: var(--success); }
.badge-missed   { background: rgba(231,76,60,.2);  color: var(--danger);  }
.badge-busy     { background: rgba(243,156,18,.2); color: var(--warning); }
.badge-failed   { background: rgba(136,136,170,.2); color: var(--text-dim); }
.badge-in       { background: rgba(52,152,219,.2); color: var(--info); }
.badge-out      { background: rgba(233,69,96,.2);  color: var(--accent); }

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
}
.btn-primary   { background: var(--accent);   color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-sm        { padding: 4px 10px; font-size: 12px; }
.btn-icon-only { padding: 6px 10px; }

/* Filters bar */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}
.filters select,
.filters input { height: 34px; min-width: 120px; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.visible { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 480px;
  max-width: 95vw;
  padding: 28px;
  animation: slideUp .2s ease;
}
.modal h2 { font-size: 18px; margin-bottom: 20px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.form-row input,
.form-row select { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Audio player */
.audio-inline { width: 100%; height: 32px; }
audio::-webkit-media-controls-panel { background: var(--surface2); }

/* Active call bar */
.active-call-bar {
  background: rgba(46,204,113,.1);
  border: 1px solid rgba(46,204,113,.3);
  border-radius: var(--radius);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.active-call-bar .pulse-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 1s infinite;
}

/* Login screen */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px;
  width: 340px;
  text-align: center;
}
.login-card h1 { font-size: 24px; color: var(--accent); margin-bottom: 8px; }
.login-card p { color: var(--text-dim); margin-bottom: 28px; font-size: 13px; }
.login-card input { width: 100%; margin-bottom: 12px; height: 40px; }
.login-card .btn { width: 100%; height: 40px; font-size: 15px; }
.login-error { color: var(--danger); font-size: 12px; margin-top: 8px; }

/* Recordings grid */
.rec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.rec-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 16px;
}
.rec-card h4 { font-size: 13px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-meta { font-size: 11px; color: var(--text-dim); margin-bottom: 10px; }
.rec-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }
  .sidebar-logo span,
  .sidebar-nav a span:not(.nav-icon),
  .sidebar-footer { display: none; }
  .main-content { margin-left: 60px; padding: 16px; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
  font-size: 13px;
}
.pagination button { padding: 4px 12px; }
.page-info { color: var(--text-dim); }

/* Toast */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  max-width: 280px;
  animation: slideLeft .2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
@keyframes slideLeft {
  from { transform: translateX(60px); opacity:0; }
  to   { transform: translateX(0);    opacity:1; }
}

/* Users table trunk dropdown inline */
.trunk-select {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 2px 6px;
  font-size: 12px;
  cursor: pointer;
}
.trunk-select:hover { border-color: var(--surface2); }
