/*
 * Cloudivator Mobile PWA — v2 light theme + IBM Plex Sans + Stripe-purple
 */

@import url('https://www.cloudivator.com/css/brand-tokens.css');

:root {
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --bg-card: #ffffff;
  --fg: #0a1628;
  --muted: #4a5568;
  --faint: #8a8f9b;
  --border: #e5e7eb;
  --primary: #635bff;
  --primary-hover: #524cd8;
  --primary-soft: rgba(99, 91, 255, 0.08);
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

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

input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  font-size: 16px;
  font-family: inherit;
}
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 91, 255, 0.15);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  border-radius: 6px;
  font-weight: 500; font-size: 15px;
  font-family: inherit;
  transition: background 0.12s, transform 0.1s;
  width: 100%;
  border: 1px solid transparent;
}
.btn:active { transform: translateY(0.5px); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: white; border-color: var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

/* ── Login screen ── */
.login-screen {
  flex: 1;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: 32px 24px;
}
.login-logo { display: none; }
.login-title {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 8px;
  color: var(--fg);
}
.login-title .brand-text { color: var(--fg) !important; background: none !important; -webkit-background-clip: initial !important; }
.login-subtitle {
  color: var(--muted);
  margin-bottom: 32px;
  text-align: center;
  font-size: 14px;
}
.pin-input {
  font-size: 28px;
  letter-spacing: 10px;
  text-align: center;
  font-weight: 600;
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

/* ── Header ── */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.95);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(8px);
}
.app-header-title {
  font-family: 'IBM Plex Sans', system-ui;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.5px;
  color: var(--fg);
}
.app-header-title svg { display: none; }
.app-header-title span { color: var(--fg) !important; }
.app-header-actions { display: flex; gap: 8px; }
.app-header-btn {
  width: 38px; height: 38px;
  border-radius: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted);
  text-decoration: none;
}
.app-header-btn:hover { color: var(--primary); border-color: var(--primary); }

/* ── Home ── */
.home {
  flex: 1;
  padding: 24px 20px;
  display: flex; flex-direction: column;
  gap: 24px;
}
.greeting {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
  color: var(--fg);
}
.greeting-sub {
  color: var(--muted);
  font-size: 14px;
}

.mic-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 20px;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: 8px;
}

.mic-button {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(99, 91, 255, 0.3);
  transition: transform 0.12s, box-shadow 0.15s;
  margin-bottom: 16px;
  border: none;
}
.mic-button:active { transform: scale(0.95); }
.mic-button.recording {
  background: var(--danger);
  animation: pulse-rec 1.5s ease-in-out infinite;
}
@keyframes pulse-rec {
  0%, 100% { box-shadow: 0 4px 16px rgba(220, 38, 38, 0.4); }
  50%      { box-shadow: 0 4px 32px rgba(220, 38, 38, 0.8), 0 0 0 12px rgba(220, 38, 38, 0.1); }
}
.mic-label { font-size: 13px; color: var(--muted); }
.mic-timer {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
  min-height: 18px;
}

.quick-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 6px;
  text-align: left;
  transition: border-color 0.12s;
}
.quick-btn:hover { border-color: var(--primary); }
.quick-btn .icon { font-size: 20px; }
.quick-btn .label {
  font-weight: 500;
  font-size: 14px;
  color: var(--fg);
}
.quick-btn .desc { color: var(--muted); font-size: 12px; }

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 8px 4px;
}

.feed-item {
  display: flex; gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
}
.feed-item:hover { border-color: var(--primary); }
.feed-item .icon { font-size: 18px; flex-shrink: 0; }
.feed-item .body { flex: 1; min-width: 0; }
.feed-item .ttl {
  font-weight: 500;
  font-size: 14px;
  color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.feed-item .sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

/* ── Sheet (modal) ── */
.sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(10, 22, 40, 0.4);
  z-index: 50;
  display: flex; align-items: flex-end;
  animation: fade-in 0.18s ease-out;
}
.sheet {
  width: 100%;
  background: var(--bg-card);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 85vh;
  overflow-y: auto;
  animation: slide-up 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes fade-in { from {opacity: 0;} to {opacity: 1;} }
@keyframes slide-up { from {transform: translateY(100%);} to {transform: translateY(0);} }

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--border-strong, #d1d5db);
  border-radius: 2px;
  margin: -8px auto 16px;
}
.sheet-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin-bottom: 12px;
  color: var(--fg);
}
.sheet-actions { display: flex; gap: 12px; margin-top: 16px; }

.transcript-block {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  margin-bottom: 12px;
  max-height: 120px; overflow-y: auto;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
}

.score-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px; font-weight: 500;
  background: var(--primary-soft);
  color: var(--primary);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
  background: var(--primary-soft);
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 6px;
  margin-bottom: 4px;
}

.plan-section {
  margin: 10px 0;
  padding: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.plan-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.plan-section ul { list-style: none; padding: 0; }
.plan-section li {
  font-size: 13px;
  padding: 6px 0;
  line-height: 1.5;
  border-bottom: 1px solid var(--divider, #f1f3f5);
}
.plan-section li:last-child { border-bottom: none; }
.plan-section p { font-size: 13px; line-height: 1.55; }

.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 20px; right: 20px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-left: 3px solid var(--success);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(10, 22, 40, 0.15);
  z-index: 100;
  animation: slide-up 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 14px;
  color: var(--fg);
}
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warning); }

.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-state {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px;
  gap: 12px;
  text-align: center;
  color: var(--muted);
}

details summary {
  list-style: none;
  cursor: pointer;
}
details summary::-webkit-details-marker { display: none; }
