/* ============================================================
   NurseStaff — Passaggio di Consegne
   Tema: clinico, calmo, native-app feel
   ============================================================ */

:root {
  --color-bg: #f4f6f8;
  --color-surface: #ffffff;
  --color-surface-2: #fafbfc;
  --color-border: #e5e7eb;
  --color-border-strong: #d1d5db;

  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-faint: #94a3b8;

  --color-primary: #0f766e;
  --color-primary-600: #0d6b63;
  --color-primary-700: #0a5b53;
  --color-primary-soft: #ccfbf1;
  --color-primary-tint: #f0fdfa;

  --color-danger: #dc2626;
  --color-danger-soft: #fee2e2;

  --color-amber: #d97706;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 2px 8px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-fab: 0 8px 24px rgba(15, 118, 110, 0.35), 0 2px 6px rgba(15, 118, 110, 0.2);

  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  --font-serif: 'Instrument Serif', Georgia, serif;

  --header-h: auto;
  --footer-h: 96px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* -------- Reset / Base -------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* -------- App shell (mobile-first, centrato su desktop) -------- */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

@media (min-width: 600px) {
  body {
    background: linear-gradient(135deg, #e2e8f0 0%, #f1f5f9 100%);
    padding: 24px 0;
  }
  .app-shell {
    border-radius: 32px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    min-height: calc(100vh - 48px);
    min-height: calc(100dvh - 48px);
  }
}

/* -------- Header -------- */
.app-header {
  background: var(--color-surface);
  padding: calc(var(--safe-top) + 16px) 16px 16px;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.app-brand {
  display: flex;
  align-items: center;
}

.app-brand__logo {
  max-height: 55px;
  width: auto;
  display: block;
}

/* Icon button generico */
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: var(--color-text-muted);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover, .icon-btn:active {
  background: var(--color-bg);
  color: var(--color-text);
}

.icon-btn--ghost {
  width: 36px;
  height: 36px;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* -------- Main / lista tracce -------- */
.app-main {
  flex: 1;
  padding: 20px 16px 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 14px;
  padding-left: 4px;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 400;
  font-style: italic;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.section-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  background: var(--color-primary-soft);
  color: var(--color-primary-700);
  font-size: 12px;
  font-weight: 600;
}

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

.empty-state__icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  color: var(--color-text-faint);
}

.empty-state__icon svg {
  width: 28px;
  height: 28px;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 6px;
}

.empty-state p {
  font-size: 13px;
  margin: 0;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

/* -------- Track list -------- */
.track-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.track-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  animation: trackEnter 0.3s ease-out;
}

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

.track-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.track-card__number {
  flex: 0 0 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background: var(--color-primary-tint);
  color: var(--color-primary-700);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
}

.track-card__name {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  min-width: 0;
}

.track-card__name:hover {
  background: var(--color-bg);
}

.track-card__name:focus {
  outline: none;
  background: var(--color-primary-tint);
  box-shadow: 0 0 0 2px var(--color-primary-soft);
}

.track-card__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
  padding-left: 34px;
  margin-bottom: 10px;
}

.track-card__sep {
  opacity: 0.5;
}

.track-card__duration {
  font-variant-numeric: tabular-nums;
}

/* Player */
.track-card__player {
  display: flex;
  align-items: center;
  gap: 12px;
}

.play-btn {
  flex: 0 0 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  display: grid;
  place-items: center;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.play-btn:hover { background: var(--color-primary-600); }
.play-btn:active { transform: scale(0.95); }

.play-btn svg {
  width: 18px;
  height: 18px;
}

.play-btn .play-btn__pause { display: none; }
.play-btn.is-playing .play-btn__play { display: none; }
.play-btn.is-playing .play-btn__pause { display: block; }

.track-card__progress {
  flex: 1;
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.track-card__progress-bar {
  height: 100%;
  width: 0%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width 0.1s linear;
}

/* -------- Transcribe action (pulsante globale sotto le tracce) -------- */
.transcribe-action {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  animation: trackEnter 0.3s ease-out;
}

.transcribe-action[hidden] { display: none; }

.btn-transcribe {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--color-text);
  color: white;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn-transcribe:hover { background: #1f2937; }
.btn-transcribe:active { transform: scale(0.99); }
.btn-transcribe:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-transcribe svg {
  width: 16px;
  height: 16px;
}

.transcribe-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-text-muted);
}

.transcribe-status[hidden] { display: none; }

.transcribe-status__spinner {
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--color-primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* -------- Footer + FAB -------- */
.bottom-spacer {
  height: calc(var(--footer-h) + var(--safe-bottom));
}

.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  pointer-events: none;
  padding-bottom: var(--safe-bottom);
}

@media (min-width: 600px) {
  .app-footer {
    position: absolute;
    border-radius: 0 0 32px 32px;
  }
}

.app-footer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--color-bg) 0%, var(--color-bg) 60%, rgba(244, 246, 248, 0) 100%);
  pointer-events: none;
}

.rec-indicator {
  position: absolute;
  bottom: calc(var(--footer-h) + 12px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--color-text);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: indicatorEnter 0.3s ease-out;
}

@keyframes indicatorEnter {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.rec-indicator__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-danger);
  animation: blinkRec 1s ease-in-out infinite;
}

@keyframes blinkRec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.rec-indicator__time {
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
  font-size: 12px;
}

.fab {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  pointer-events: auto;
  box-shadow: var(--shadow-fab);
  display: grid;
  place-items: center;
  transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.fab:hover { background: var(--color-primary-600); }
.fab:active { transform: translateX(-50%) scale(0.95); }

.fab__inner {
  display: grid;
  place-items: center;
  position: relative;
}

.fab svg {
  width: 28px;
  height: 28px;
}

.fab .fab__icon-stop { display: none; }

.fab.is-recording {
  background: var(--color-danger);
  box-shadow: 0 8px 24px rgba(220, 38, 38, 0.4), 0 2px 6px rgba(220, 38, 38, 0.25);
  animation: fabPulse 1.6s ease-in-out infinite;
}

.fab.is-recording .fab__icon-mic { display: none; }
.fab.is-recording .fab__icon-stop { display: block; }
.fab.is-recording svg { width: 22px; height: 22px; }

@keyframes fabPulse {
  0%, 100% {
    box-shadow: 0 8px 24px rgba(220, 38, 38, 0.4), 0 2px 6px rgba(220, 38, 38, 0.25), 0 0 0 0 rgba(220, 38, 38, 0.4);
  }
  50% {
    box-shadow: 0 8px 24px rgba(220, 38, 38, 0.4), 0 2px 6px rgba(220, 38, 38, 0.25), 0 0 0 14px rgba(220, 38, 38, 0);
  }
}

/* -------- Toast -------- */
.toast-host {
  position: fixed;
  bottom: calc(var(--footer-h) + 24px + var(--safe-bottom));
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}

.toast {
  background: var(--color-text);
  color: white;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.25s ease-out;
  pointer-events: auto;
}

.toast--error { background: var(--color-danger); }
.toast--success { background: var(--color-primary); }

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

.toast.is-leaving {
  animation: toastOut 0.2s ease-in forwards;
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px); }
}

/* -------- Permission overlay -------- */
.permission-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.permission-overlay[hidden] { display: none; }

.permission-overlay__card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: trackEnter 0.3s ease-out;
}

.permission-overlay__icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-danger-soft);
  color: var(--color-danger);
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
}

.permission-overlay__icon svg {
  width: 26px;
  height: 26px;
}

.permission-overlay h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 8px;
}

.permission-overlay p {
  font-size: 14px;
  color: var(--color-text-muted);
  margin: 0 0 20px;
  line-height: 1.5;
}
