/* PBX Portal — shared styles for index.html and pbx-admin/index.html */

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

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --radius: 8px;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

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

/* ===== Header ===== */
.portal-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-label {
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.breadcrumb {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

/* ===== Main content ===== */
.portal-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  font-weight: 700;
}

.subtitle {
  margin: 0 0 2rem;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ===== Landing card grid ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

a.card {
  text-decoration: none;
  color: inherit;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
  display: block;
}

a.card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.card p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ===== Admin card sections ===== */
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.admin-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ===== Auth prompt ===== */
.auth-prompt {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 480px;
  margin: 3rem auto;
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-prompt h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.auth-prompt p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0 0 1.5rem;
}

/* ===== Form elements ===== */
.form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  min-width: 180px;
  flex: 1;
}

.form-group label {
  font-weight: 500;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
}

.form-group input,
.form-group select {
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ===== Extension table ===== */
.ext-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.ext-table th,
.ext-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.ext-table th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.ext-table input[type="text"] {
  width: 100%;
  padding: 0.375rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
}

.ext-table input[type="text"].description-field {
  font-family: inherit;
}

.ext-num {
  font-family: monospace;
  font-weight: 600;
}

/* ===== Toggle switch ===== */
.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  display: inline-block;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  border-radius: 22px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* ===== Deploy section ===== */
.deploy-section {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.deploy-info {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.key-preview {
  font-family: monospace;
  background: var(--bg);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-size: 0.875rem;
  border: 1px solid var(--border);
}

/* ===== XML preview ===== */
.xml-preview {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 1rem;
  border-radius: var(--radius);
  overflow: auto;
  max-height: 60vh;
  font-family: monospace;
  font-size: 0.8rem;
  white-space: pre;
  line-height: 1.4;
}

/* ===== Modal ===== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border-radius: 12px;
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  overflow: auto;
  padding: 1.5rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.125rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
}

/* ===== Toast notifications ===== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: toast-in 0.2s ease;
  max-width: 340px;
}

.toast-success { background: #dcfce7; color: #166534; border-left: 4px solid var(--success); }
.toast-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--error); }
.toast-warning { background: #fef9c3; color: #854d0e; border-left: 4px solid var(--warning); }
.toast-info    { background: #dbeafe; color: #1e40af; border-left: 4px solid var(--info); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------------------------------
   Utility classes — replace inline style= attributes for CSP compliance.
   The portal CSP omits 'unsafe-inline' from style-src so all styles must
   be in external CSS files.
   ------------------------------------------------------------------------ */

/* Initially-hidden elements toggled by JS via classList.add/remove('hidden') */
.hidden { display: none; }

/* Page header row: title + action button side-by-side */
.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

/* Auth form: full-width button */
.btn-full-width { width: 100%; }

/* Small button text (e.g. Sign out) */
.btn-sm-text { font-size: 0.8rem; }

/* Auth error message */
.auth-error {
  color: var(--error);
  font-size: 0.875rem;
  margin-top: 0.75rem;
}

/* Hint paragraph with bottom margin */
.hint-mb { margin-bottom: 1rem; }

/* Flex-width variants for form-group in a form-row */
.form-group-wide   { flex: 2; }
.form-group-narrow { flex: 1; }

/* Key preview badge (shown after saving API key config) */
.key-preview-badge { font-size: 0.875rem; }

/* Extension table column widths */
.col-ext     { width: 80px; }
.col-cli     { width: 200px; }
.col-enabled { width: 80px; }

/* Narrow modal (e.g. deploy confirm dialog) */
.modal-content-sm { max-width: 500px; }

/* Button row with right-aligned buttons */
.btn-row-right { justify-content: flex-end; }

/* ===== Call agents card (Sprint 183, pbx-admin) ===== */
.admin-card h3 {
  margin: 1.5rem 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.col-actions { width: 170px; }

.ca-actions { white-space: nowrap; }

.ca-actions .btn { padding: 0.25rem 0.625rem; font-size: 0.8rem; }

.ca-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.7rem;
  font-weight: 600;
}

.ca-note {
  background: #fef9c3;
  color: #854d0e;
  border-left: 4px solid var(--warning);
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.ca-form {
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.ca-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.ca-checks label { display: inline-flex; align-items: center; gap: 0.35rem; }

.ca-checks-label { font-weight: 500; }

/* ===== Landing page: the tenant sign-in card and the operator heading (series-2 Sprint 11) ===== */
.card-wide {
  margin-bottom: 2rem;
  border-color: var(--primary);
}

.section-heading {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}
