/* ==========================================================================
   AG TOOL — Shared Design System
   Premium, minimal, light theme. Used by generate.php, verify.php, index.php
   ========================================================================== */

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

:root {
  /* Surfaces */
  --bg: #ffffff;
  --bg-alt: #f6f7fb;
  --surface: #ffffff;
  --border: #e7e9f2;
  --border-soft: #eef0f8;

  /* Text */
  --navy: #0b1730;
  --text: #16213e;
  --text-secondary: #5c6478;
  --text-muted: #8a90a4;

  /* Accent */
  --primary: #3452e1;
  --primary-dark: #2538a8;
  --primary-soft: #eef1fd;
  --indigo: #5b4fe0;

  /* Status */
  --success: #1f9d55;
  --success-soft: #e9f9ef;
  --danger: #e5484d;
  --danger-soft: #fdeceb;
  --warning: #b7791f;
  --warning-soft: #fdf3e2;

  /* Shape */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(16, 24, 64, 0.06);
  --shadow-md: 0 10px 30px rgba(16, 24, 64, 0.08);
  --shadow-lg: 0 20px 50px rgba(16, 24, 64, 0.12);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-alt);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Remove ugly default tap/focus rectangles, keep a11y focus ring */
a, button, input, textarea, select, [tabindex] {
  outline: none;
}
:focus {
  outline: none;
}
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 6px;
}
button::-moz-focus-inner {
  border: 0;
}

img, svg {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 20px;
}

.container-wide {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px;
}

/* Page shell used on generate.php / verify.php */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.page-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
}

/* Top brand bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  max-width: 1080px;
  margin: 0 auto;
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 16px;
  color: var(--navy);
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--indigo));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

/* Cards */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 28px 24px;
  width: 100%;
  overflow: hidden;
  animation: fadeInUp 0.5s var(--ease) both;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--indigo));
  opacity: 0.9;
}

.card + .card {
  margin-top: 16px;
}

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

/* Icon badge */
.icon-badge {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.icon-badge.success { background: var(--success-soft); color: var(--success); }
.icon-badge.danger { background: var(--danger-soft); color: var(--danger); }
.icon-badge.warning { background: var(--warning-soft); color: var(--warning); }

/* Typography */
.h1 {
  font-size: 21px;
  font-weight: 800;
  color: var(--navy);
  text-align: center;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 6px;
}
.subtext {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.55;
  margin: 0;
}
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  text-align: center;
  display: block;
  margin-bottom: 8px;
}

/* Buttons */
.btn {
  appearance: none;
  border: none;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease), opacity 0.15s var(--ease);
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 8px 20px rgba(52, 82, 225, 0.28);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 24px rgba(52, 82, 225, 0.34); }
.btn-primary:active { transform: translateY(0); box-shadow: 0 4px 10px rgba(52, 82, 225, 0.28); }

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.btn-secondary:hover { background: #e3e7fb; }

.btn:disabled {
  background: #e4e6ef;
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Notice / instruction box */
.notice {
  background: var(--bg-alt);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 16px;
  text-align: left;
}
.notice strong { color: var(--navy); }
.notice ol, .notice ul {
  margin: 8px 0 0;
  padding-left: 18px;
}
.notice li { margin-bottom: 4px; }

/* Timer */
.timer-ring {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 6px auto 14px;
  font-size: 30px;
  font-weight: 800;
  color: var(--primary-dark);
  border: 3px solid var(--primary);
  animation: pulseRing 1s ease-in-out infinite;
}
@keyframes pulseRing {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 82, 225, 0.18); }
  50% { box-shadow: 0 0 0 8px rgba(52, 82, 225, 0); }
}

/* Video embed */
.video-frame {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--navy);
  margin-top: 4px;
  box-shadow: var(--shadow-sm);
}
.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.video-fallback {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-alt);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  margin-top: 4px;
}

/* Info row (device id etc.) */
.meta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 18px;
  word-break: break-all;
  text-align: center;
}

/* Language switcher */
.lang-switch {
  display: flex;
  gap: 6px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
}
.lang-switch button {
  appearance: none;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.lang-switch button.active {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

/* Social row */
.social-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 6px;
}
.social-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  transition: background 0.15s var(--ease), transform 0.15s var(--ease), border-color .15s var(--ease);
}
.social-btn:hover { background: var(--primary-soft); border-color: #d7ddfb; transform: translateY(-1px); }
.social-btn svg { flex-shrink: 0; }

/* Footer */
.site-footer {
  text-align: center;
  padding: 22px 16px 28px;
  font-size: 12px;
  color: var(--text-muted);
}
.site-footer .credit {
  font-weight: 600;
  color: var(--text-secondary);
}
.site-footer .credit b { color: var(--navy); }

/* Status states */
.status-title {
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 6px;
}
.status-title.danger { color: var(--danger); }
.status-title.success { color: var(--success); }
.status-title.warning { color: var(--warning); }

/* Responsive tweaks */
@media (min-width: 640px) {
  .container { max-width: 480px; }
  .card { padding: 34px 32px; }
}

@media (max-width: 380px) {
  .card { padding: 22px 18px; border-radius: var(--radius-md); }
  .h1 { font-size: 19px; }
}

/* ===================== Admin dashboard ===================== */
.admin-body { background: var(--bg-alt); }
.admin-shell { max-width: 1080px; margin: 0 auto; padding: 24px 18px 48px; }
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.admin-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--navy);
  margin: 0;
}
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 18px;
}
.admin-card h3 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
}
.admin-shell input[type="text"],
.admin-shell input[type="password"],
.admin-shell input[type="number"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg-alt);
  color: var(--text);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.admin-shell input:focus-visible {
  border-color: var(--primary);
  background: var(--surface);
}
.admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  color: #fff;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  transition: transform .15s var(--ease), opacity .15s var(--ease);
}
.admin-btn:hover { transform: translateY(-1px); opacity: .95; }
.admin-btn.green { background: var(--success); }
.admin-btn.blue { background: var(--primary); }
.admin-btn.red { background: var(--danger); }
.admin-btn.orange { background: #e08a2c; }

.table-responsive { overflow-x: auto; border-radius: var(--radius-sm); }
.admin-shell table { width: 100%; border-collapse: collapse; min-width: 640px; }
.admin-shell th, .admin-shell td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
}
.admin-shell th {
  background: var(--bg-alt);
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .04em;
}
.badge {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  display: inline-block;
}
.bg-success { background: var(--success); }
.bg-danger { background: var(--danger); }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 6px; }
.inline-form input[type="number"] { width: 70px; }

.admin-login-wrap {
  max-width: 380px;
  margin: 14vh auto 0;
  padding: 0 18px;
}
.admin-login-wrap .admin-card { text-align: center; }
.error-text { color: var(--danger); font-size: 13px; margin: 0 0 10px; }
.success-text { color: var(--success); font-size: 13px; margin: 0 0 10px; }

@media (max-width: 560px) {
  .admin-shell th, .admin-shell td { font-size: 12.5px; padding: 10px; }
}
