/* ==========================================================================
   OTP Viewer — Dark mode, minimal, mobile-first
   ========================================================================== */

/* --- Reset & Base ------------------------------------------------------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #242836;
  --border:    #2e3345;
  --text:      #e4e6ef;
  --text-dim:  #8b8fa3;
  --accent:    #6c5ce7;
  --accent-hv: #5a4bd1;
  --danger:    #e74c3c;
  --danger-hv: #c0392b;
  --success:   #2ecc71;
  --radius:    12px;
  --font:      'SF Pro Display', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.container {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

/* --- Header ------------------------------------------------------------- */
header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.875rem;
}

/* --- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hv); transform: translateY(-1px); }

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

.btn-outline {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  width: 100%;
  margin-top: 0.25rem;
}
.btn-outline:hover { background: var(--surface2); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  width: 100%;
  margin-top: 1.5rem;
}
.btn-danger:hover { background: var(--danger-hv); }

.btn-copy {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  width: 100%;
  margin-top: 1rem;
  transition: all 0.2s ease;
}
.btn-copy:hover { background: rgba(108,92,231,0.12); }
.btn-copy.copied {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* --- Scan Section ------------------------------------------------------- */
.scan-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.scan-options {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.scan-options .btn { flex: 1; min-width: 140px; }

/* --- Webcam ------------------------------------------------------------- */
.webcam-controls {
  margin-top: 1rem;
}

.webcam-preview-wrapper {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
  margin-bottom: 0.75rem;
  background: #000;
  aspect-ratio: 4/3;
}

.webcam-preview-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Scanning overlay with animated box */
.scan-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scan-box {
  width: 60%;
  aspect-ratio: 1;
  border: 2px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.4);
  animation: scan-pulse 1.5s ease-in-out infinite;
}

@keyframes scan-pulse {
  0%, 100% { border-color: var(--accent); box-shadow: 0 0 0 9999px rgba(0,0,0,0.4), 0 0 15px rgba(108,92,231,0.3); }
  50% { border-color: var(--success); box-shadow: 0 0 0 9999px rgba(0,0,0,0.4), 0 0 25px rgba(46,204,113,0.4); }
}

/* --- Status ------------------------------------------------------------- */
.status {
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  display: none;
}

.status.show { display: block; }

.status.error {
  background: rgba(231, 76, 60, 0.15);
  color: #e74c3c;
  border: 1px solid rgba(231, 76, 60, 0.3);
}

.status.success {
  background: rgba(46, 204, 113, 0.15);
  color: #2ecc71;
  border: 1px solid rgba(46, 204, 113, 0.3);
}

.status.info {
  background: rgba(108, 92, 231, 0.15);
  color: #a29bfe;
  border: 1px solid rgba(108, 92, 231, 0.3);
}

/* --- OTP Display -------------------------------------------------------- */
.otp-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  border: 1px solid var(--border);
}

/* Account selector (multi-account from migration) */
.account-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.account-selector select {
  flex: 1;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b8fa3' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.btn-delete-acct {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.btn-delete-acct:hover {
  background: rgba(231,76,60,0.15);
  color: var(--danger);
  border-color: rgba(231,76,60,0.3);
}

.account-count {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
  background: var(--surface2);
  padding: 0.35rem 0.6rem;
  border-radius: 20px;
}

.account-label {
  font-size: 0.95rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.secret-badge {
  display: inline-block;
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  margin-bottom: 1.5rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  letter-spacing: 0.05em;
}

/* Circular countdown */
.otp-circle-wrapper {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 1rem;
}

.otp-circle {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.otp-circle-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 8;
}

.otp-circle-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 565.48;  /* 2 * π * 90 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.4s ease;
}

.otp-circle-progress.warning {
  stroke: #f39c12;
}

.otp-circle-progress.danger {
  stroke: var(--danger);
}

.otp-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.otp-code {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  color: var(--text);
  line-height: 1;
}

.otp-timer {
  font-size: 0.95rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
  font-weight: 500;
}

/* --- Footer ------------------------------------------------------------- */
footer {
  text-align: center;
  margin-top: 2rem;
  color: var(--text-dim);
  font-size: 0.75rem;
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 380px) {
  .otp-code { font-size: 2.5rem; }
  .otp-circle-wrapper { width: 170px; height: 170px; }
  .scan-options { flex-direction: column; }
}
