/* ============================================
   Pledge PWA — Design System
   Mobile-first, max-width 480px
   ============================================ */

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

:root {
  --primary: #FFAB00;
  --primary-dark: #FF8F00;
  --success: #4CAF50;
  --error: #F44336;
  --bg: #F5F5F5;
  --card-bg: #FFFFFF;
  --text: #212121;
  --text-secondary: #757575;
  --border: #E0E0E0;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

html, body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* === Page === */
.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  min-height: 100dvh;
  animation: fadeIn 200ms ease;
}

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

/* === Card === */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* === Typography === */
h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* === Forms === */
.form-group {
  margin-bottom: 16px;
}

.input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  outline: none;
  transition: border-color 200ms ease;
}

.input:focus {
  border-color: var(--primary);
}

/* === Buttons === */
.btn {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: all 200ms ease;
  margin-top: 12px;
}

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

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

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

.btn--success:hover { background: #43A047; }

.btn--text {
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
}

.btn--text:hover { color: var(--text); }

.btn--loading {
  opacity: 0.6;
  pointer-events: none;
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* === Click Button === */
.click-button {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: var(--primary);
  border: none;
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 24px auto;
  transition: transform 100ms ease;
  box-shadow: 0 4px 12px rgba(255,171,0,0.3);
}

.click-button:active,
.click-button--pressed {
  transform: scale(0.95);
}

.click-button--disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* === Timer === */
.timer {
  font-family: 'Courier New', monospace;
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin: 16px 0;
}

.timer--critical {
  color: var(--error);
  animation: pulse 1s infinite;
}

.timer--expired {
  color: var(--error);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* === Progress Bar === */
.progress-container {
  margin: 16px 0;
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 300ms ease;
}

.progress-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 6px;
}

/* === Stepper === */
.stepper {
  margin-bottom: 16px;
}

.stepper-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.stepper-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
}

.stepper-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
}

.stepper-btn:hover {
  border-color: var(--primary);
  background: #FFF8E1;
}

.stepper-value {
  font-size: 24px;
  font-weight: 700;
  min-width: 48px;
  text-align: center;
}

/* === Sticker Notes === */
.sticker {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  margin: 12px 0;
  animation: slideDown 300ms ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.sticker--info {
  background: #FFF9C4;
  border: 1px solid #FDD835;
  color: #F57F17;
}

.sticker--success {
  background: #C8E6C9;
  border: 1px solid #4CAF50;
  color: #2E7D32;
}

.sticker--error {
  background: #FFCDD2;
  border: 1px solid #F44336;
  color: #C62828;
}

/* === Badges === */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}

.badge--draft { background: #E0E0E0; color: #757575; }
.badge--active { background: #FFF3E0; color: #E65100; }
.badge--success { background: #E8F5E9; color: #2E7D32; }
.badge--failed { background: #FFEBEE; color: #C62828; }

/* === Page-specific === */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.page-header h1 { margin-bottom: 0; }

.page-header .btn {
  width: auto;
  padding: 10px 16px;
  font-size: 14px;
  margin-top: 0;
}

.contracts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contract-card {
  cursor: pointer;
  transition: box-shadow 200ms ease;
}

.contract-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.contract-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.contract-name {
  font-size: 20px;
  text-align: center;
}

.contract-desc {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 8px;
}

.deposit-info {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary-dark);
  margin: 8px 0;
}

.price-note {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin: 12px 0;
}

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

.loading {
  text-align: center;
  color: var(--text-secondary);
  padding: 48px 0;
}

.app-version {
  position: fixed;
  bottom: 8px;
  right: 12px;
  font-size: 10px;
  color: rgba(0, 0, 0, 0.25);
  pointer-events: none;
  user-select: none;
  z-index: 9999;
}

/* === Consent Page === */
.consent-contract-summary {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
}

.consent-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.consent-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.consent-params {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.consent-param {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.consent-param--deposit .consent-param-value {
  color: var(--primary-dark);
  font-size: 20px;
}

.consent-param-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 500;
}

.consent-param-value {
  font-size: 16px;
  font-weight: 700;
}

.consent-info {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
  padding: 12px;
  background: #FFF9C4;
  border-radius: var(--radius-sm);
  border: 1px solid #FDD835;
}

.consent-toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.consent-checkbox {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.consent-label {
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  line-height: 1.4;
  margin-bottom: 0;
}

.consent-support {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 8px;
}

.consent-support a {
  color: var(--primary-dark);
  text-decoration: none;
}

.consent-support a:hover {
  text-decoration: underline;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  color: var(--primary-dark);
  cursor: pointer;
  text-decoration: underline;
  display: inline;
  width: auto;
  margin: 0;
}

.btn-link:hover {
  color: var(--primary);
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 150ms ease;
}

.modal-card {
  background: var(--card-bg);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 200ms ease;
}

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

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

.modal-header h1 {
  font-size: 18px;
  margin-bottom: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
  width: auto;
  margin: 0;
}

.modal-body p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
}
