/* ─────────────────────────────────────────────
   SignGO – Dark Mode Apple-Style UI
   ───────────────────────────────────────────── */

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

:root {
  /* Apple system colours */
  --bg-primary:   #000000;
  --bg-secondary: #1C1C1E;
  --bg-tertiary:  #2C2C2E;
  --bg-elevated:  #3A3A3C;

  --text-primary:   #FFFFFF;
  --text-secondary: #EBEBF5CC; /* 80 % white */
  --text-tertiary:  #EBEBF566; /* 40 % white */

  --accent:         #0A84FF; /* iOS blue */
  --accent-hover:   #409CFF;
  --success:        #30D158; /* iOS green */
  --success-hover:  #34D962;
  --warning:        #FF9F0A; /* iOS orange */
  --warning-hover:  #FFB340;
  --danger:         #FF453A;

  --separator:      rgba(84, 84, 88, 0.65);
  --radius:         16px;
  --radius-sm:      10px;
  --shadow:         0 8px 32px rgba(0,0,0,.6);

  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

html, body {
  min-height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Helvetica Neue", Arial, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ── Header ──────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(28, 28, 30, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
}

.header-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.badge {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
  transition: opacity .3s;
}
.badge:empty { display: none; }
.badge.active   { background: var(--success); color: #000; }
.badge.revoked  { background: var(--danger);  color: #fff; }
.badge.pending  { background: var(--warning); color: #000; }

/* ── Main ────────────────────────────────────── */
.main {
  flex: 1;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Card ────────────────────────────────────── */
.card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow);
  animation: fadeUp .35s ease;
}

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

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -.2px;
}

.card-body {
  font-size: .9375rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 20px;
}

/* ── Input ───────────────────────────────────── */
.input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: var(--bg-tertiary);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: "SF Mono", "Courier New", monospace;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  outline: none;
  transition: border-color .2s;
}
.input:focus       { border-color: var(--accent); }
.input::placeholder { color: var(--text-tertiary); letter-spacing: .5px; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s, transform .1s, opacity .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--accent);   color: #fff; }
.btn-primary:hover  { background: var(--accent-hover); }

.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); margin-top: 10px; }
.btn-secondary:hover { background: #48484A; }

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

.btn-warning  { background: var(--warning);  color: #000; }
.btn-warning:hover  { background: var(--warning-hover); }

/* ── Spinner ─────────────────────────────────── */
.spinner,
.btn-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.spinner { margin: 0 auto 4px; }

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

/* ── Status row ──────────────────────────────── */
.status-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
}

.status-row p {
  font-size: .9375rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ── Hint ────────────────────────────────────── */
.hint {
  margin-top: 14px;
  font-size: .8125rem;
  color: var(--text-tertiary);
  text-align: center;
  line-height: 1.5;
}

/* ── Error message ───────────────────────────── */
.error-msg {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(255, 69, 58, .15);
  border: 1px solid rgba(255, 69, 58, .4);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: #FF6961;
  line-height: 1.5;
}

.signing-progress {
  margin-top: 14px;
}

.signing-progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  overflow: hidden;
}

.signing-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width .35s ease;
}

.install-guidance {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--separator);
}

.guide-block h3 {
  font-size: .95rem;
  margin-bottom: 10px;
}

.guide-block p,
.guide-block li {
  font-size: .875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.guide-block ol {
  margin-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qr-image {
  display: block;
  width: 220px;
  height: 220px;
  margin: 12px auto 8px;
  border-radius: 10px;
  background: #fff;
}

.qr-link {
  word-break: break-all;
  font-size: .75rem;
  color: var(--text-tertiary);
  text-align: center;
  margin-bottom: 10px;
}

/* ── Utility ─────────────────────────────────── */
.hidden { display: none !important; }

/* ── Footer ──────────────────────────────────── */
.footer {
  text-align: center;
  padding: 20px;
  font-size: .75rem;
  color: var(--text-tertiary);
  border-top: 1px solid var(--separator);
}

/* ── Responsive (small screens) ─────────────── */
@media (max-width: 400px) {
  .main   { padding: 20px 14px; }
  .card   { padding: 20px 16px; }
}
