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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f2f5;
  color: #1a1a1a;
  min-height: 100vh;
}

/* ── Topbar ── */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  background: #fff;
  border-bottom: 1px solid #ebebeb;
  position: sticky;
  top: 0;
  z-index: 10;
}
#app-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #111;
}
#app-name .blue { color: #007aff; }
#topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}
#user-name { color: #555; font-weight: 500; }
#admin-link {
  color: #007aff;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}
#admin-link:hover { text-decoration: underline; }
#logout-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  transition: background 0.15s;
}
#logout-btn:hover { background: #f5f5f7; }

/* ── Layout ── */
#app {
  display: flex;
  gap: 16px;
  padding: 20px 24px;
  max-width: 1200px;
  margin: 0 auto;
  align-items: flex-start;
}

/* ── Left column ── */
#left-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 260px;
  flex-shrink: 0;
}

/* ── Phone panel ── */
#phone-panel {
  background: #fff;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}
#phone-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
#status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #ccc;
  flex-shrink: 0;
  transition: background 0.3s;
}
#status-dot.ready      { background: #34c759; }
#status-dot.calling    { background: #ff9500; animation: pulse 1s infinite; }
#status-dot.oncall     { background: #007aff; }
#status-dot.error      { background: #ff3b30; }
#status-dot.connecting { background: #ccc; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.25} }
#status-text { font-size: 13px; color: #888; font-weight: 500; }

#number-input {
  width: 100%;
  border: none;
  border-bottom: 2px solid #e0e0e0;
  background: transparent;
  padding: 6px 4px;
  font-size: 22px;
  font-weight: 300;
  color: #111;
  letter-spacing: 2px;
  margin-bottom: 12px;
  outline: none;
  text-align: center;
  transition: border-color 0.2s;
}
#number-input:focus { border-bottom-color: #007aff; }
#number-input::placeholder { color: #bbb; font-size: 14px; letter-spacing: 0; }

#dialpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 12px;
}
.digit {
  background: #f5f5f7;
  border: none;
  border-radius: 10px;
  padding: 10px 0;
  font-size: 16px;
  font-weight: 400;
  color: #111;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  transition: background 0.1s, transform 0.08s;
  user-select: none;
}
.digit span { font-size: 7px; color: #888; margin-top: 2px; letter-spacing: 1px; }
.digit:hover  { background: #e8e8ed; }
.digit:active { background: #d1d1d6; transform: scale(0.95); }
.digit.plus-key { color: #007aff; font-weight: 600; }

#transcribe-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
  cursor: pointer;
  font-size: 12px;
  color: #555;
}
#transcribe-toggle input { width: 15px; height: 15px; accent-color: #007aff; cursor: pointer; }

#call-controls { display: flex; gap: 8px; }
#call-btn, #hangup-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
#call-btn  { background: #34c759; color: #fff; }
#call-btn:disabled  { background: #c8e6c9; color: #a5d6a7; cursor: not-allowed; }
#hangup-btn { background: #ff3b30; color: #fff; }
#hangup-btn:disabled { background: #ffcdd2; color: #ef9a9a; cursor: not-allowed; }
#call-btn:not(:disabled):hover, #hangup-btn:not(:disabled):hover { opacity: 0.85; }
#call-timer { text-align: center; margin-top: 10px; font-size: 13px; font-weight: 600; color: #007aff; }

/* ── Side panels (Dossiers + Contacts) ── */
#dossiers-panel, #contacts-panel {
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

.side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #888;
}
.icon-btn {
  background: #f0f0f0;
  border: none;
  border-radius: 6px;
  width: 22px;
  height: 22px;
  font-size: 14px;
  font-weight: 700;
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s;
}
.icon-btn:hover { background: #e0e0e0; color: #007aff; }

/* Dossier items */
.dossier-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}
.dossier-item:hover { background: #f5f5f7; }
.dossier-item.active-filter { background: #eef4ff; color: #007aff; font-weight: 600; }
.dossier-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dossier-item .dossier-label { flex: 1; font-size: 13px; }
.dossier-item .dossier-count {
  font-size: 11px;
  color: #aaa;
  background: #f0f0f0;
  border-radius: 10px;
  padding: 1px 6px;
}
.dossier-item.active-filter .dossier-count { background: #cde0ff; color: #007aff; }
.dossier-actions {
  display: none;
  gap: 4px;
}
.dossier-item:hover .dossier-actions { display: flex; }
.dossier-action-btn {
  background: none;
  border: none;
  font-size: 12px;
  cursor: pointer;
  color: #aaa;
  padding: 1px 3px;
  border-radius: 4px;
  transition: color 0.1s, background 0.1s;
}
.dossier-action-btn:hover { color: #555; background: #e8e8ed; }

.side-empty { font-size: 12px; color: #ccc; text-align: center; padding: 10px 0; }

/* Contact items */
.contact-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
}
.contact-item:hover { background: #f5f5f7; }
.contact-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #007aff;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.contact-info { flex: 1; min-width: 0; }
.contact-info .contact-name { font-size: 13px; font-weight: 600; color: #111; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-info .contact-phone { font-size: 11px; color: #aaa; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-edit-btn {
  background: none;
  border: none;
  font-size: 12px;
  color: #ccc;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: none;
}
.contact-item:hover .contact-edit-btn { display: block; color: #888; }
.contact-edit-btn:hover { background: #e8e8ed; color: #333; }

/* ── Log panel ── */
#log-panel {
  flex: 1;
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  min-height: 400px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  min-width: 0;
}
#log-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
#log-header h2 { font-size: 18px; font-weight: 700; color: #111; }
#log-subtitle   { font-size: 12px; color: #aaa; margin-top: 2px; }
#log-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Time filter buttons */
#time-filters {
  display: flex;
  gap: 4px;
  background: #f5f5f7;
  border-radius: 10px;
  padding: 3px;
}
.filter-btn {
  background: none;
  border: none;
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.filter-btn:hover { background: #e8e8ed; color: #333; }
.filter-btn.active {
  background: #fff;
  color: #111;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

#refresh-btn {
  background: #f5f5f7;
  border: none;
  color: #555;
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s;
}
#refresh-btn:hover { background: #e8e8ed; color: #007aff; }
.empty-state { color: #bbb; font-size: 14px; text-align: center; padding: 48px 0; }

/* ── Call entries ── */
.call-entry {
  border: 1px solid #ebebeb;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 14px;
}
.call-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 10px;
  cursor: pointer;
  background: #fff;
  transition: background 0.1s;
}
.call-entry-header:hover { background: #fafafa; }
.call-number { font-size: 16px; font-weight: 600; color: #111; }
.call-meta   { font-size: 12px; color: #999; padding: 0 16px 10px; }

/* Dossier selector in call entry */
.dossier-select-row {
  padding: 0 16px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dossier-select {
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  color: #555;
  background: #fff;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
  max-width: 200px;
}
.dossier-select:focus { border-color: #007aff; }

.dossier-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: #f0f0f0;
  color: #555;
}
.dossier-tag .dot { width: 7px; height: 7px; border-radius: 50%; }

/* ── Transcription ── */
.transcript-section {
  padding: 14px 16px;
}
.transcript-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #007aff;
  margin-bottom: 8px;
}
.transcript-text {
  font-size: 14px;
  line-height: 1.75;
  color: #222;
  white-space: pre-wrap;
  background: #f7f9ff;
  border-left: 3px solid #007aff;
  border-radius: 0 10px 10px 0;
  padding: 12px 14px;
}

/* Collapsible */
.transcript-collapsible {
  transition: max-height 0.3s ease;
}
.transcript-collapsible.collapsed {
  max-height: 180px;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}
.transcript-toggle {
  display: block;
  width: 100%;
  margin: 6px 0 0;
  background: none;
  border: none;
  font-size: 12px;
  color: #007aff;
  cursor: pointer;
  text-align: center;
  padding: 4px;
  font-weight: 600;
}
.transcript-toggle:hover { text-decoration: underline; }

.transcript-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
  gap: 6px;
}
.transcript-source { font-size: 11px; color: #aaa; }
.transcript-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.transcript-copy-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 11px;
  color: #555;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.transcript-copy-btn:hover { background: #f0f0f0; }

/* Transcription diarisée */
.transcript-block {
  border-left: 3px solid #007aff;
  padding: 8px 12px;
  margin-bottom: 10px;
  border-radius: 0 8px 8px 0;
  background: #f7f9ff;
}
.transcript-block-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 3px;
}
.transcript-speaker {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.transcript-time {
  font-size: 11px;
  color: #aaa;
  font-variant-numeric: tabular-nums;
}
.transcript-block-text {
  font-size: 14px;
  line-height: 1.6;
  color: #222;
  margin: 0;
}

/* Bouton téléchargement MP3 */
.call-audio {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 16px 12px;
  border-bottom: 1px solid #f0f0f0;
}
.call-audio audio {
  flex: 1;
  height: 34px;
  border-radius: 8px;
  outline: none;
}
.download-btn {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: #007aff;
  text-decoration: none;
  background: #eef4ff;
  border-radius: 8px;
  padding: 5px 10px;
  white-space: nowrap;
  transition: background 0.15s;
}
.download-btn:hover { background: #dde9ff; }

/* Action buttons */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 12px 16px;
  padding: 7px 16px;
  border: none;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: #007aff;
  color: #fff;
  transition: opacity 0.15s;
}
.action-btn:hover    { opacity: 0.82; }
.action-btn:disabled { background: #b0d0f5; cursor: not-allowed; }

.pending-info {
  font-size: 12px;
  color: #aaa;
  font-style: italic;
  padding: 10px 16px;
}

/* Bouton supprimer appel */
.delete-call-btn {
  background: none;
  border: none;
  font-size: 15px;
  cursor: pointer;
  color: #ccc;
  padding: 2px 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.delete-call-btn:hover { color: #ff3b30; background: #fff0f0; }

/* Status badges */
.status-badge {
  display: inline-block;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 600;
}
.status-badge.initiated    { background: #f0f0f0; color: #888; }
.status-badge.recorded     { background: #fff3e0; color: #e65100; }
.status-badge.transcribing { background: #e3f2fd; color: #1565c0; }
.status-badge.transcribed  { background: #e8f5e9; color: #2e7d32; }

/* ── Modals ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 20px;
  padding: 28px 28px 24px;
  width: 400px;
  max-width: 95vw;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
}
.modal h3 { font-size: 17px; font-weight: 700; margin-bottom: 20px; color: #111; }
.modal-field {
  margin-bottom: 14px;
}
.modal-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  margin-bottom: 6px;
}
.modal-field input, .modal-field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  resize: vertical;
}
.modal-field input:focus, .modal-field textarea:focus { border-color: #007aff; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.btn {
  padding: 9px 20px;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary { background: #007aff; color: #fff; }
.btn-primary:hover { opacity: 0.85; }
.btn-secondary { background: #f0f0f0; color: #333; }
.btn-secondary:hover { background: #e0e0e0; }
.btn-danger { background: #ff3b30; color: #fff; }
.btn-danger:hover { opacity: 0.85; }

/* Color picker */
#color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: #111; }

/* ── Responsive ── */
@media (max-width: 800px) {
  #app { flex-direction: column; padding: 16px; }
  #left-col { width: 100%; flex-direction: row; flex-wrap: wrap; }
  #phone-panel { flex: 1; min-width: 260px; }
  #dossiers-panel, #contacts-panel { flex: 1; min-width: 200px; }
}
