/* ============================================================
   Asterisk Dashboard — Dark Theme
   ============================================================ */

:root {
  --bg-base:       #0f1117;
  --bg-surface:    #1a1d27;
  --bg-card:       #20243a;
  --bg-hover:      #262b3e;
  --border:        #2e3348;
  --accent:        #4f7cff;
  --accent-hover:  #3a64e8;
  --text-primary:  #e2e8f0;
  --text-secondary:#8b92a8;
  --text-muted:    #565e78;
  --green:         #22c55e;
  --yellow:        #eab308;
  --red:           #ef4444;
  --radius:        8px;
  --sidebar-width: 200px;
  --shadow:        0 2px 8px rgba(0,0,0,.4);
}

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

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
}

.hidden { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #c53030; }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

.error-msg { color: var(--red); font-size: 13px; padding: 6px 0; }

input, select, textarea {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select option { background: var(--bg-surface); }
label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--text-secondary); }
.form-group { margin-bottom: 14px; }

/* Login */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  width: 340px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 28px;
  text-align: center;
}

/* App shell */
.app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-logo {
  padding: 20px 16px 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}
.nav-list { list-style: none; padding: 10px 0; flex: 1; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.active { background: var(--bg-hover); color: var(--accent); font-weight: 500; }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
#nav-username { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Main content */
.main-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.view { padding: 20px; flex: 1; }
.view-title { font-size: 20px; font-weight: 600; margin-bottom: 16px; }

/* AMI status bar */
.ami-status-bar {
  background: #7c2d12; color: #fde68a;
  padding: 8px 16px; font-size: 13px; text-align: center;
  border-bottom: 1px solid #92400e;
}

/* Queue cards */
.queues-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 16px;
}
.queue-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.queue-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.queue-name { font-size: 15px; font-weight: 600; }
.queue-stats { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); }

.agent-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.agent-row:last-child { border-bottom: none; }
.agent-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot-available   { background: var(--green); }
.dot-in_call     { background: var(--red); }
.dot-paused      { background: var(--yellow); }
.dot-unavailable { background: var(--text-muted); }
.agent-name { flex: 1; }
.agent-status { font-size: 11px; color: var(--text-secondary); }
.agent-call-info { font-size: 11px; color: var(--text-muted); text-align: right; }
.agent-actions { display: flex; gap: 4px; margin-left: 6px; }

.waiting-header {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px; margin: 10px 0 6px;
}
.waiting-row { display: flex; gap: 12px; font-size: 12px; padding: 3px 0; }
.waiting-pos { width: 18px; color: var(--text-muted); }
.waiting-num { flex: 1; color: var(--text-primary); }
.waiting-time { color: var(--text-muted); }

/* Filters */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 16px; align-items: flex-end;
}
.filters .form-group { margin-bottom: 0; }
.filters input, .filters select { width: 150px; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 9px 12px;
  background: var(--bg-surface); color: var(--text-secondary);
  font-weight: 500; font-size: 11px; text-transform: uppercase;
  letter-spacing: .4px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: var(--bg-hover); }
tr.clickable { cursor: pointer; }

/* Chain */
.chain-row td { padding: 0; }
.chain-inner { background: var(--bg-base); padding: 0 12px 8px; }
.chain-table { background: transparent; margin: 0; }
.chain-table th { background: transparent; font-size: 10px; }
.chain-table td { font-size: 12px; color: var(--text-secondary); }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.badge-ANSWERED  { background: #14532d; color: #86efac; }
.badge-NO\ ANSWER { background: #422006; color: #fdba74; }
.badge-BUSY      { background: #450a0a; color: #fca5a5; }
.badge-FAILED    { background: #1c1917; color: #a8a29e; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; color: var(--text-secondary); }
.pagination .btn { min-width: 36px; justify-content: center; }

/* Recording */
.rec-controls { display: flex; align-items: center; gap: 4px; }
.rec-controls audio { height: 32px; width: 300px; min-width: 200px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  width: 420px; max-width: 95vw; box-shadow: var(--shadow);
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Contacts */
.contact-tel { color: var(--accent); text-decoration: none; }
.contact-tel:hover { text-decoration: underline; }

/* Toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.toolbar-left, .toolbar-right { display: flex; gap: 8px; align-items: center; }

/* Empty state */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }

/* Import result */
.import-result {
  margin-top: 10px; padding: 10px 14px;
  background: var(--bg-base); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 12px; color: var(--text-secondary);
}
.import-result .ok { color: var(--green); }
.import-result .warn { color: var(--yellow); }

.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
