/* ══════════════════════════════════════════════
   Quick Capture PWA — Stylesheet
   Warm cream + coral action colors
   ══════════════════════════════════════════════ */

:root {
  /* Warm cream base (aligned with PKA dashboard) */
  --bg: #faf8f5;
  --card: #ffffff;
  --text: #3d3329;
  --text-light: #8a7e72;
  --text-muted: #b0a59a;
  --border: #ece6dd;
  --accent-soft: #f3ead8;

  /* Energizing action colors */
  --primary: #c47d6d;
  --primary-dark: #a85d4e;
  --primary-light: #e8a99b;
  --primary-glow: rgba(196, 125, 109, 0.25);
  --success: #8fba7f;
  --success-bg: #f0f7ed;
  --warning: #d4a853;
  --warning-bg: #faf5e8;
  --danger: #c0392b;
  --danger-bg: #fce8e6;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Typography */
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Lora', Georgia, serif;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 2px 12px rgba(60, 50, 40, 0.06);
  --shadow-hover: 0 4px 20px rgba(60, 50, 40, 0.1);
  --shadow-capture: 0 4px 24px rgba(196, 125, 109, 0.2);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ── LOGIN PAGE ── */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-xl);
  background: linear-gradient(160deg, #faf8f5 0%, #f3ead8 100%);
}

.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-capture);
}

.login-logo span {
  color: #fff;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
}

.login-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: var(--space-xl);
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: var(--space-sm);
}

.form-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a7e72' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.pin-input-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: var(--space-sm);
}

.pin-digit {
  width: 44px;
  height: 52px;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  font-family: var(--font);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
}

.pin-digit:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow-capture);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 28px rgba(196, 125, 109, 0.3); }
.btn-primary:active { transform: scale(0.98); }

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-full { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

.login-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-top: var(--space-sm);
  min-height: 20px;
}

/* ── APP SHELL ── */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px var(--space-md);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-bar-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.top-bar-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}

.top-bar-version {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pending-badge {
  display: none;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.pending-badge.show { display: inline-block; }

.offline-dot {
  display: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
}

.offline-dot.show { display: block; }

.btn-logout {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

/* ── MAIN CONTENT ── */
.main-content {
  flex: 1;
  padding: var(--space-md);
  padding-bottom: 80px;
}

.app-section { display: block; }
.app-section.hidden { display: none !important; }

#section-capture {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 160px);
}

#section-capture .capture-grid {
  margin-top: auto;
  margin-bottom: auto;
  margin-left: auto;
  margin-right: auto;
}

/* ── CAPTURE GRID ── */
.capture-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: 400px;
  margin: 0 auto;
  padding-top: var(--space-md);
}

.capture-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 140px;
  max-height: 140px;
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.capture-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(255,255,255,0.15) 0%, transparent 50%);
  pointer-events: none;
}

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

.capture-btn-photo {
  background: linear-gradient(135deg, #c47d6d 0%, #b06458 100%);
  box-shadow: 0 4px 20px rgba(196, 125, 109, 0.3);
}

.capture-btn-text {
  background: linear-gradient(135deg, #d4a853 0%, #c09540 100%);
  box-shadow: 0 4px 20px rgba(212, 168, 83, 0.3);
}

.capture-btn-voice {
  background: linear-gradient(135deg, #7d9fc4 0%, #6889b0 100%);
  box-shadow: 0 4px 20px rgba(125, 159, 196, 0.3);
}

.capture-btn-video {
  background: linear-gradient(135deg, #8fba7f 0%, #78a568 100%);
  box-shadow: 0 4px 20px rgba(143, 186, 127, 0.3);
}

.capture-btn-icon {
  font-size: 36px;
  line-height: 1;
  color: #fff;
  position: relative;
}

.capture-btn-label {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  position: relative;
}

.capture-greeting {
  text-align: center;
  padding: var(--space-lg) 0 var(--space-sm);
}

.capture-greeting h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.capture-greeting p {
  font-size: 13px;
  color: var(--text-light);
}

/* ── TEXT CAPTURE OVERLAY ── */
.text-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.text-overlay.show {
  opacity: 1;
  visibility: visible;
}

.text-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px var(--space-md);
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.text-overlay-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
}

.text-overlay-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.text-overlay-body {
  flex: 1;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
}

.text-capture-input {
  flex: 1;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  resize: none;
  outline: none;
}

.text-capture-input::placeholder {
  color: var(--text-muted);
}

.text-overlay-footer {
  padding: var(--space-md);
  padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--card);
  transition: transform 0.15s ease;
}

/* ── VOICE RECORDING OVERLAY ── */
.recording-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(61, 51, 41, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.recording-overlay.show {
  opacity: 1;
  visibility: visible;
}

.recording-pulse {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-ring 1.5s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.4);
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.4); }
  70% { box-shadow: 0 0 0 20px rgba(192, 57, 43, 0); }
  100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0); }
}

.recording-pulse-icon {
  font-size: 32px;
  color: #fff;
}

.recording-timer {
  font-size: 40px;
  font-weight: 300;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.recording-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-stop-recording {
  padding: 16px 48px;
  border: 2px solid #fff;
  border-radius: 40px;
  background: transparent;
  color: #fff;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-top: 16px;
}

.btn-stop-recording:active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.96);
}

/* ── BOTTOM SHEET ── */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(61, 51, 41, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.bottom-sheet-overlay.show {
  opacity: 1;
  visibility: visible;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 401;
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-lg);
  padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

.bottom-sheet.show {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto var(--space-lg);
}

.bottom-sheet-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 10px;
}

.bottom-sheet-option:last-child { margin-bottom: 0; }

.bottom-sheet-option:active {
  background: var(--accent-soft);
  transform: scale(0.98);
}

.bottom-sheet-option-icon {
  font-size: 22px;
  width: 28px;
  text-align: center;
}

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 6px 0;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 200;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item-icon {
  font-size: 22px;
  line-height: 1;
}

/* ── HISTORY CARDS ── */
.history-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.history-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.history-count {
  font-size: 12px;
  color: var(--text-light);
}

.history-total {
  text-align: center;
  padding: var(--space-sm) 0;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.capture-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px var(--space-md);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}

.capture-card:active {
  box-shadow: var(--shadow-hover);
}

.capture-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.capture-card-icon.photo { background: rgba(196, 125, 109, 0.12); color: var(--primary); }
.capture-card-icon.text { background: rgba(212, 168, 83, 0.12); color: var(--warning); }
.capture-card-icon.voice { background: rgba(125, 159, 196, 0.12); color: #7d9fc4; }
.capture-card-icon.video { background: rgba(143, 186, 127, 0.12); color: var(--success); }

.capture-card-body {
  flex: 1;
  min-width: 0;
}

.capture-card-preview {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.capture-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.capture-card-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.capture-card-status.synced { background: var(--success); }
.capture-card-status.pending { background: var(--warning); }

.empty-state {
  text-align: center;
  padding: 48px var(--space-lg);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.empty-state-text {
  font-size: 15px;
  line-height: 1.5;
}

/* ── ADMIN PANEL ── */
.admin-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: var(--space-lg);
}

.admin-tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-light);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.admin-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(196, 125, 109, 0.25);
}

.admin-section { display: block; }
.admin-section.hidden { display: none; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(61, 51, 41, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

.modal-overlay.show .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
}

.modal-title {
  font-weight: 600;
  font-size: 16px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  padding: var(--space-md) var(--space-lg);
  padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  z-index: 700;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

/* ── LOADING ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(250, 248, 245, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── FORM CONTROLS ── */
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

/* ── RESPONSIVE ── */
@media (min-width: 768px) {
  .capture-grid { max-width: 500px; }
  .capture-btn { min-height: 160px; max-height: 160px; }

  .modal-overlay { align-items: center; }
  .modal {
    border-radius: var(--radius-lg);
    max-height: 80vh;
  }
  .modal-overlay.show .modal { transform: translateY(0); }
}

/* ── HIDDEN FILE INPUTS ── */
.hidden-input { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }

/* ── USER LIST (Admin) ── */
.user-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px var(--space-md);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.user-card-info {
  display: flex;
  flex-direction: column;
}

.user-card-name {
  font-weight: 600;
  font-size: 15px;
}

.user-card-role {
  font-size: 12px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.user-card-actions {
  display: flex;
  gap: 8px;
}

/* ── MEDIA PREVIEW ── */
.media-preview {
  width: 100%;
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
  max-height: 300px;
  object-fit: contain;
  background: var(--bg);
}

audio.media-preview {
  max-height: 54px;
}
