/* ==========================================================================
   Court Transfer Certificate Generator - Mobile iOS Stylesheet
   Designed for iPhone Safari, iOS PWA, and Senior Staff Accessibility
   ========================================================================== */

:root {
  --primary: #5b21b6;
  --primary-hover: #4c1d95;
  --primary-light: #f5f3ff;
  --primary-border: #ddd6fe;
  --accent: #7c3aed;
  --accent-gradient: linear-gradient(135deg, #6d28d9 0%, #4f46e5 100%);
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --muted: #64748b;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --border-card: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #475569;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px -1px rgba(91, 33, 182, 0.08), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 28px -4px rgba(91, 33, 182, 0.15), 0 4px 12px -2px rgba(0, 0, 0, 0.05);
  --font-system: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  font-family: var(--font-system);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  padding-top: calc(var(--safe-top) + 64px);
  padding-bottom: calc(var(--safe-bottom) + 90px);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Header (iOS Glassmorphism)
   ========================================================================== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--safe-top) + 64px);
  padding-top: var(--safe-top);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 18px;
  padding-right: 18px;
  z-index: 100;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(91, 33, 182, 0.2);
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.3px;
  line-height: 1.15;
}

.brand-subtitle {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.btn-icon {
  background: #f1f5f9;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:active {
  transform: scale(0.92);
  background: #e2e8f0;
}

/* ==========================================================================
   Main Container & Layout
   ========================================================================== */
.main-content {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
}

/* ==========================================================================
   AI Smart Camera Card
   ========================================================================== */
.ai-camera-card {
  background: linear-gradient(135deg, #ffffff 0%, #faf5ff 100%);
  border: 1.5px solid var(--primary-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.ai-camera-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.ai-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.ai-badge {
  background: var(--accent-gradient);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: 0.4px;
}

.ai-card-title {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-main);
}

.ai-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.upload-button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.btn-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 10px;
  background: #ffffff;
  border: 1.5px dashed #cbd5e1;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  font-family: inherit;
}

.btn-upload:active {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: scale(0.98);
}

.btn-upload .icon {
  font-size: 1.6rem;
}

.btn-upload .label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.btn-upload .sublabel {
  font-size: 0.72rem;
  color: var(--muted);
}

/* Hidden native file inputs */
.hidden-file-input {
  display: none;
}

/* Thumbnail Gallery */
.thumbnail-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 2px;
  margin-top: 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.thumbnail-strip::-webkit-scrollbar {
  display: none;
}

.thumb-item {
  position: relative;
  flex: 0 0 84px;
  height: 110px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 2px solid #e2e8f0;
  background: #000;
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.thumb-del {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(220, 38, 38, 0.85);
  color: #fff;
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-analyze-ai {
  width: 100%;
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(109, 40, 217, 0.3);
  transition: all 0.15s ease;
  margin-top: 12px;
}

.btn-analyze-ai:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-analyze-ai:active:not(:disabled) {
  transform: scale(0.98);
}

/* AI Status Banner */
.ai-status-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  display: none;
  align-items: center;
  gap: 10px;
}

.ai-status-box.loading {
  display: flex;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  color: var(--primary);
}

.ai-status-box.success {
  display: flex;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.ai-status-box.error {
  display: flex;
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  color: var(--danger);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(124, 58, 237, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Step Indicator Bar
   ========================================================================== */
.step-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-card);
  padding: 8px 12px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  scrollbar-width: none;
}

.step-nav-bar::-webkit-scrollbar {
  display: none;
}

.step-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.step-tab.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.step-tab.completed {
  color: var(--success);
}

.step-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.step-tab.active .step-circle {
  background: var(--primary);
  color: #fff;
}

.step-tab.completed .step-circle {
  background: var(--success);
  color: #fff;
}

/* ==========================================================================
   Form Cards & Steps
   ========================================================================== */
.step-panel {
  display: none;
}

.step-panel.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

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

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}

.card-title {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.card-subtitle {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 16px;
}

/* Form Groups */
.form-group {
  margin-bottom: 18px;
}

.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.form-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: #334155;
}

.form-label .req {
  color: var(--danger);
  margin-left: 2px;
}

/* AI Review Badges */
.review-chip {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
  letter-spacing: 0.2px;
}

.chip-extracted {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.chip-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.chip-notfound {
  background: #f1f5f9;
  color: #94a3b8;
}

.chip-edited {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

/* Inputs & Textareas */
.form-control {
  width: 100%;
  padding: 13px 14px;
  font-size: 0.98rem;
  font-family: inherit;
  color: var(--text-main);
  background-color: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 33, 182, 0.12);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
}

textarea.form-control {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}

.form-help {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 5px;
}

/* Radio Pill Selector */
.pill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.pill-option {
  position: relative;
}

.pill-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.pill-label {
  display: block;
  padding: 12px 10px;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  background: #fff;
  transition: all 0.15s ease;
}

.pill-option input[type="radio"]:checked + .pill-label {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

/* Date Helpers */
.date-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-date-helper {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
}

.btn-date-helper:active {
  background: #e2e8f0;
}

/* ==========================================================================
   Review Summary Screen
   ========================================================================== */
.review-item {
  border-bottom: 1px solid #f1f5f9;
  padding: 12px 0;
}

.review-item:last-child {
  border-bottom: none;
}

.review-k {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}

.review-v {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: pre-wrap;
}

/* ==========================================================================
   Fixed Bottom Navigation Bar (iOS Thumb Ergonomics)
   ========================================================================== */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(226, 232, 240, 0.8);
  padding: 12px 18px calc(var(--safe-bottom) + 12px) 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 100;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
}

.btn-nav-back {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-nav-back:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-nav-next {
  flex: 1;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(91, 33, 182, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-nav-next:active {
  background: var(--primary-hover);
  transform: scale(0.98);
}

.btn-nav-generate {
  background: var(--accent-gradient);
  box-shadow: 0 6px 18px rgba(109, 40, 217, 0.35);
}

/* ==========================================================================
   Modals (History & Download)
   ========================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  background: #ffffff;
  width: 100%;
  max-width: 580px;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 24px 20px calc(var(--safe-bottom) + 24px) 20px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.download-success-box {
  text-align: center;
  padding: 20px 0;
}

.success-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--accent-gradient);
  color: #fff;
  text-decoration: none;
  padding: 16px;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(109, 40, 217, 0.3);
  margin-top: 18px;
}

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

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  background: #fafafa;
}

.history-item:active {
  background: var(--primary-light);
}

.history-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.history-meta {
  font-size: 0.74rem;
  color: var(--muted);
}

.btn-preset-chip {
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  color: #5b21b6;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-preset-chip:active {
  background: #ddd6fe;
  transform: scale(0.96);
}

/* ==========================================================================
   Website Access Lock Screen (Ref: media_1794242895814_afb317a5.jpg)
   ========================================================================== */
.lock-screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(6, 8, 15, 0.86);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lock-card {
  width: 100%;
  max-width: 380px;
  background: #0f131f;
  border: 1.5px solid #00f2fe;
  border-radius: 20px;
  padding: 32px 24px;
  box-shadow: 0 0 30px rgba(0, 242, 254, 0.22), 0 20px 50px rgba(0, 0, 0, 0.7);
  text-align: center;
  animation: lockScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes lockScaleIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.lock-title {
  color: #00f2fe;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 22px;
}

.lock-input-group {
  margin-bottom: 16px;
}

.lock-input {
  width: 100%;
  padding: 14px 16px;
  background: #181d2e;
  border: 1px solid #2a334d;
  border-radius: 10px;
  color: #ffffff;
  font-size: 1.15rem;
  text-align: center;
  letter-spacing: 4px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.lock-input:focus {
  outline: none;
  border-color: #00f2fe;
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.3);
}

.lock-input::placeholder {
  letter-spacing: 0px;
  font-size: 0.92rem;
  color: #64748b;
}

.btn-unlock {
  width: 100%;
  padding: 14px 16px;
  background: #00f2fe;
  color: #04121c;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 242, 254, 0.35);
  transition: all 0.15s ease;
}

.btn-unlock:active {
  transform: scale(0.98);
  background: #38bdf8;
}

.lock-error {
  color: #f87171;
  font-size: 0.8rem;
  margin-top: 12px;
  display: none;
}

.lock-shake {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

