/* CasePulse — mobile-first, calm clinical UI */

:root {
  --navy: #0f1a2e;
  --navy-light: #1a2744;
  --navy-card: #162035;
  --off-white: #e8e6e1;
  --off-white-dim: #a8a6a1;
  --green: #3dba7a;
  --green-hover: #34a56c;
  --green-dim: rgba(61, 186, 122, 0.15);
  --red: #e05c5c;
  --red-dim: rgba(224, 92, 92, 0.15);
  --radius: 12px;
  --nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--navy);
  color: var(--off-white);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
}

/* Screens */
.screen {
  display: none;
  padding: 20px 16px 0;
  animation: fadeIn 0.2s ease;
}

.screen.active {
  display: block;
}

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

.screen-header {
  margin-bottom: 24px;
}

.screen-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--off-white-dim);
  font-size: 0.875rem;
  margin-top: 2px;
}

/* Microphone */
.mic-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.mic-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: none;
  background: var(--green);
  color: var(--navy);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.mic-btn:active {
  transform: scale(0.95);
}

.mic-btn.recording {
  background: var(--red);
  color: white;
  box-shadow: 0 0 0 8px var(--red-dim);
  animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 8px var(--red-dim); }
  50% { box-shadow: 0 0 0 16px rgba(224, 92, 92, 0.05); }
}

.mic-icon {
  width: 40px;
  height: 40px;
}

.mic-status {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--off-white-dim);
}

.manual-link {
  margin-top: 8px;
  background: none;
  border: none;
  color: var(--off-white-dim);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px 12px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  font-family: inherit;
}

.manual-link:active {
  color: var(--green);
}

/* Transcript */
.transcript-box {
  background: var(--navy-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid rgba(232, 230, 225, 0.08);
}

.transcript-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--off-white-dim);
  margin-bottom: 8px;
}

.transcript-text {
  font-size: 0.95rem;
  min-height: 1.5em;
  word-break: break-word;
}

/* Error banner */
.error-banner {
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.875rem;
  color: #f5b0b0;
}

/* Form */
.case-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--off-white-dim);
  margin-bottom: 6px;
}

.optional {
  font-weight: 400;
  opacity: 0.7;
}

.form-row input,
.form-row textarea {
  width: 100%;
  background: var(--navy-card);
  border: 1px solid rgba(232, 230, 225, 0.12);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--off-white);
  font-size: 1rem;
  font-family: inherit;
  -webkit-appearance: none;
  transition: border-color 0.15s;
}

.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--green);
}

.form-row textarea {
  resize: vertical;
  min-height: 60px;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:not(:disabled):active {
  background: var(--green-hover);
}

.btn-secondary {
  background: var(--navy-light);
  color: var(--off-white);
  border: 1px solid rgba(232, 230, 225, 0.15);
}

.btn-accent {
  background: var(--green);
  color: var(--navy);
  margin-top: 8px;
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
  margin-top: 16px;
}

.btn-small {
  width: auto;
  padding: 8px 16px;
  font-size: 0.85rem;
  background: var(--navy-light);
  color: var(--off-white-dim);
  border: 1px solid rgba(232, 230, 225, 0.12);
}

/* Teaching points */
.teaching-section {
  margin-top: 24px;
}

.teaching-section h2 {
  font-size: 1.1rem;
  margin-bottom: 14px;
}

.teaching-card {
  background: var(--navy-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  border-left: 3px solid var(--green);
}

.teaching-card h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green);
  margin-bottom: 8px;
}

.teaching-card p {
  font-size: 0.95rem;
  line-height: 1.55;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 26, 46, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(232, 230, 225, 0.15);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#loading-text {
  font-size: 0.9rem;
  color: var(--off-white-dim);
}

/* History */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--navy-card);
  border-radius: var(--radius);
}

.filter-row {
  flex: 1;
  min-width: 120px;
}

.filter-row label {
  display: block;
  font-size: 0.75rem;
  color: var(--off-white-dim);
  margin-bottom: 4px;
}

.filter-row input[type="date"] {
  width: 100%;
  background: var(--navy);
  border: 1px solid rgba(232, 230, 225, 0.12);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--off-white);
  font-size: 0.9rem;
  color-scheme: dark;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: var(--navy-card);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  border: 1px solid rgba(232, 230, 225, 0.06);
  transition: border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.history-item:active {
  border-color: var(--green);
}

.history-item-date {
  font-size: 0.75rem;
  color: var(--off-white-dim);
  margin-bottom: 4px;
}

.history-item-complaint {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 4px;
}

.history-item-summary {
  font-size: 0.85rem;
  color: var(--off-white-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  text-align: center;
  color: var(--off-white-dim);
  padding: 40px 20px;
  font-size: 0.9rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-content {
  position: relative;
  background: var(--navy);
  border-radius: 16px 16px 0 0;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  width: 100%;
  max-width: 480px;
  max-height: 85dvh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--off-white-dim);
  font-size: 1.5rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
  padding-right: 40px;
}

.detail-section {
  margin-bottom: 16px;
}

.detail-section h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green);
  margin-bottom: 4px;
}

.detail-section p {
  font-size: 0.95rem;
}

/* Settings */
.settings-card {
  background: var(--navy-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.settings-card label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.settings-card input[type="password"],
.settings-card input[type="text"] {
  width: 100%;
  background: var(--navy);
  border: 1px solid rgba(232, 230, 225, 0.12);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--off-white);
  font-size: 1rem;
  margin-bottom: 12px;
}

.settings-card input:focus {
  outline: none;
  border-color: var(--green);
}

.settings-card h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.settings-note {
  font-size: 0.85rem;
  color: var(--off-white-dim);
  line-height: 1.5;
  margin-bottom: 12px;
}

.success-msg {
  color: var(--green);
  font-size: 0.85rem;
  margin-top: 8px;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--navy-light);
  border-top: 1px solid rgba(232, 230, 225, 0.08);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  max-width: 480px;
  margin: 0 auto;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--off-white-dim);
  cursor: pointer;
  padding: 8px 20px;
  font-size: 0.7rem;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color 0.15s;
}

.nav-btn svg {
  width: 24px;
  height: 24px;
}

.nav-btn.active {
  color: var(--green);
}

/* Utilities */
.hidden {
  display: none !important;
}
