/* ==========================================================================
   Callmeister Portal – Dark-Grey CI Theme
   Basis: Callmeister Onepager CI (#16273F navy, #55BDC7 accent)
   Portal-Variante: dunkleres Grau als Basis
   ========================================================================== */

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

:root {
  /* Portal Dark-Grey Palette */
  --bg-body:       #1A1D23;
  --bg-surface:    #22262E;
  --bg-card:       #2A2F38;
  --bg-card-hover: #323842;
  --bg-input:      #2A2F38;

  /* Accent from Callmeister CI */
  --accent:        #55BDC7;
  --accent-hover:  #44A8B2;
  --accent-soft:   rgba(85, 189, 199, 0.12);
  --accent-glow:   rgba(85, 189, 199, 0.20);

  /* Navy (used sparingly) */
  --navy:          #16273F;

  /* Text */
  --text-primary:  #E8ECF1;
  --text-secondary:#9BA3B0;
  --text-muted:    #6B7280;

  /* Borders */
  --border:        rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);

  /* Shadows */
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:     0 4px 20px rgba(0,0,0,0.25);
  --shadow-lg:     0 12px 40px rgba(0,0,0,0.35);

  /* Fonts (same as Onepager) */
  --font-heading:  'Exo 2', system-ui, sans-serif;
  --font-body:     'Asap', system-ui, sans-serif;

  /* Status colors */
  --green:         #34D399;
  --yellow:        #FBBF24;
  --red:           #F87171;
}

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

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

/* ==========================================================================
   Loading Overlay
   ========================================================================== */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-body);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s;
}
.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Header
   ========================================================================== */

.portal-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text-primary);
}

.brand-badge {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 4px;
}

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

.dealer-badge {
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
}

.dealer-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
}
.btn-logout:hover {
  color: var(--red);
  border-color: var(--red);
}

/* ==========================================================================
   Main
   ========================================================================== */

.portal-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* ==========================================================================
   Stats Row
   ========================================================================== */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: border-color 0.2s;
}
.stat-card:hover {
  border-color: var(--accent-soft);
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ==========================================================================
   Filters
   ========================================================================== */

.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 240px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 10px 12px 10px 38px;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}
.search-box input:focus {
  border-color: var(--accent);
}
.search-box input::placeholder {
  color: var(--text-muted);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 10px 14px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
}
.filter-group select:focus {
  border-color: var(--accent);
}

.btn-icon {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 9px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.2s;
}
.btn-icon:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ==========================================================================
   Table
   ========================================================================== */

.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

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

.call-table thead {
  background: var(--bg-surface);
}

.call-table th {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

.call-table tbody tr {
  transition: background 0.15s;
  cursor: pointer;
}
.call-table tbody tr:hover {
  background: var(--bg-card-hover);
}
.call-table tbody tr:last-child td {
  border-bottom: none;
}

/* Cell helpers */
.cell-time {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-phone {
  font-family: 'SF Mono', 'Cascadia Code', monospace;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.cell-name {
  font-weight: 600;
  color: var(--text-primary);
}

.cell-vehicle {
  font-size: 0.85rem;
}
.cell-vehicle .plate {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.8rem;
  margin-right: 6px;
}

.cell-summary {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.cell-duration {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-actions .btn-detail {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.cell-actions .btn-detail:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.badge-identified {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.badge-identified.yes { background: var(--green); }
.badge-identified.no  { background: var(--text-muted); }

/* ==========================================================================
   Empty State
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.4;
}
.empty-state p {
  font-size: 0.95rem;
}

/* ==========================================================================
   Modal
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  width: 100%;
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.modal-body .detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px 16px;
}

.detail-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  padding-top: 2px;
}

.detail-value {
  color: var(--text-primary);
  font-size: 0.95rem;
}

.detail-transcript {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.detail-transcript h3 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.transcript-line {
  padding: 6px 0;
  font-size: 0.9rem;
  line-height: 1.5;
}
.transcript-line .speaker {
  font-weight: 600;
  margin-right: 8px;
}
.transcript-line .speaker.agent { color: var(--accent); }
.transcript-line .speaker.user  { color: var(--text-secondary); }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .portal-main { padding: 16px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .call-table th:nth-child(4),
  .call-table td:nth-child(4),
  .call-table th:nth-child(5),
  .call-table td:nth-child(5) { display: none; }
  .modal-card { padding: 20px; }
  .modal-body .detail-grid { grid-template-columns: 1fr; gap: 6px; }
}
