/* ============================================================
   HyperGuard – Garanti Belgesi Sistemi
   ============================================================ */

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

:root {
  --bg-0: #07090f;
  --bg-1: #0f1320;
  --bg-2: #161c2c;
  --bg-3: #1d2436;
  --bg-elev: #232b40;
  --border: #2a334a;
  --border-strong: #3a455e;

  --text: #e9edf5;
  --text-muted: #97a1b8;
  --text-faint: #6f7891;

  --primary: #e11d48;       /* HyperGuard kırmızısı */
  --primary-strong: #be123c;
  --secondary: #2563eb;     /* HyperGuard mavisi */
  --accent: #22c55e;        /* Active part green */

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
}

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background:
    radial-gradient(900px 600px at 80% -10%, rgba(225, 29, 72, 0.18), transparent 60%),
    radial-gradient(800px 500px at 0% 110%, rgba(37, 99, 235, 0.15), transparent 60%),
    var(--bg-0);
  min-height: 100vh;
}

a { color: inherit; }
button { font-family: inherit; }
input, button, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

.hidden { display: none !important; }

/* =================== Buttons =================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 12px 20px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  box-shadow: 0 8px 20px rgba(225, 29, 72, 0.3), inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 10px 26px rgba(225, 29, 72, 0.42), inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--bg-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-block { width: 100%; }
.btn-large { padding: 16px 28px; font-size: 16px; }

/* =================== Login =================== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
}
.login-bg-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(600px 400px at 50% 50%, rgba(225, 29, 72, 0.15), transparent 70%);
  pointer-events: none;
}
.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo {
  width: 180px;
  height: auto;
  margin: 0 auto 8px;
  display: block;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.35));
  background: #fff;
  padding: 6px;
  border-radius: 12px;
}
.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  margin-top: 18px;
}
.login-subtitle {
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 24px;
  font-size: 14px;
}
.login-form { text-align: left; }
.login-form .field { margin-bottom: 14px; }
.error-text {
  color: #fda4af;
  font-size: 13px;
  text-align: center;
  min-height: 18px;
  margin-top: 12px;
}

/* =================== Form fields =================== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.2px;
  text-transform: uppercase;
}
.field input[type="text"],
.field input[type="password"],
.field input[type="date"] {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.field input:focus {
  border-color: var(--primary);
  background: var(--bg-3);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.18);
}
.field input.uppercase { text-transform: uppercase; letter-spacing: 0.5px; }
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

/* =================== App layout =================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
  background: rgba(7, 9, 15, 0.75);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-logo {
  height: 48px;
  width: auto;
  background: #fff;
  padding: 4px 8px;
  border-radius: 8px;
}
.header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-tag {
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}
.page-title { margin-bottom: 22px; }
.page-title h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.page-title p {
  color: var(--text-muted);
  margin-top: 6px;
}

.form-card {
  background: linear-gradient(180deg, var(--bg-1), #0c1120);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px;
}
.form-section {
  padding: 22px 22px 26px;
  border-bottom: 1px solid var(--border);
}
.form-section:last-of-type,
.form-section.hidden + .form-section,
.form-section:nth-last-of-type(1) {
  border-bottom: 0;
}
.section-header {
  margin-bottom: 16px;
}
.section-header h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.1px;
}
.section-hint {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.grid-1 {
  display: grid;
  grid-template-columns: minmax(0, 280px);
  gap: 16px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* Radio cards */
.radio-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 720px) {
  .radio-row { grid-template-columns: 1fr; }
}
.radio-card {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.06s ease;
}
.radio-card:hover { border-color: var(--border-strong); background: var(--bg-3); }
.radio-card input { position: absolute; opacity: 0; pointer-events: none; }
.radio-card-content {
  display: flex;
  align-items: center;
  gap: 12px;
}
.radio-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.radio-label {
  font-weight: 600;
  font-size: 14.5px;
}
.radio-card input:checked ~ .radio-card-content .radio-icon {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  border-color: transparent;
}
.radio-card:has(input:checked) {
  border-color: var(--primary);
  background: linear-gradient(180deg, rgba(225, 29, 72, 0.10), var(--bg-2));
  box-shadow: inset 0 0 0 1px var(--primary);
}

/* =================== Switches =================== */
.parts-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .parts-layout { grid-template-columns: 1fr; }
}

.parts-controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.parts-presets, .parts-list {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.parts-presets h4, .parts-list h4 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.switch-list { display: flex; flex-direction: column; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px dashed rgba(255,255,255,0.05);
  cursor: pointer;
  user-select: none;
}
.switch-row:last-child { border-bottom: 0; }
.switch-row:hover .switch-label { color: #fff; }
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-label {
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
  transition: color 0.2s;
}
.switch-meta {
  font-size: 12px;
  color: var(--text-faint);
}

.preset-row { padding: 12px 6px; }
.preset-row .switch-label { font-weight: 600; font-size: 14.5px; }

.switch-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex: 0 0 auto;
}
.switch-toggle input {
  opacity: 0;
  width: 0; height: 0;
  position: absolute;
}
.switch-toggle .slider {
  position: absolute;
  inset: 0;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.switch-toggle .slider::before {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #cbd5e1;
  transition: transform 0.2s ease, background 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.switch-toggle input:checked + .slider {
  background: linear-gradient(135deg, var(--accent), #16a34a);
  border-color: transparent;
}
.switch-toggle input:checked + .slider::before {
  transform: translateX(20px);
  background: #fff;
}

/* =================== Car SVG =================== */
.parts-illustration {
  position: sticky;
  top: 90px;
}
.illustration-frame {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.car-svg {
  width: 100%;
  max-width: 320px;
  height: auto;
  display: block;
  user-select: none;
}
.car-svg .panel,
.car-svg .window-part {
  fill: #2a3146;
  stroke: #4a5775;
  stroke-width: 1.4;
  cursor: pointer;
  transition: fill 0.25s ease, stroke 0.25s ease, filter 0.25s ease;
}
.car-svg .panel:hover,
.car-svg .window-part:hover {
  fill: #353e57;
  stroke: #94a3b8;
}
.car-svg .panel.active,
.car-svg .window-part.active {
  fill: var(--accent);
  stroke: #15803d;
  filter: drop-shadow(0 0 6px rgba(34, 197, 94, 0.45));
}
.car-svg .car-detail {
  fill: rgba(148, 163, 184, 0.10);
  stroke: rgba(148, 163, 184, 0.30);
  stroke-width: 1;
}
.car-svg .car-body {
  fill: #1a2034;
  stroke: #3a455e;
  stroke-width: 1.6;
}
.car-svg .headlight { fill: rgba(255, 209, 102, 0.45); }
.car-svg .taillight { fill: rgba(225, 29, 72, 0.55); }
.car-svg .wheel { fill: #0c0f17; stroke: #2a334a; stroke-width: 1; }
.car-svg .hint-line { stroke: rgba(148, 163, 184, 0.18); stroke-width: 1; stroke-dasharray: 4 4; }

/* =================== Form actions =================== */
.form-actions {
  padding: 22px;
  display: flex;
  justify-content: flex-end;
}

.app-footer {
  margin-top: 24px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
}

/* =================== Loading overlay =================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 15, 0.78);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text);
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =================== PDF (offscreen rendering) =================== */
/* The template is positioned visibly at the top-left during PDF
   generation. The loading overlay (z-index 100) covers it so the user
   never sees the raw template. html2canvas can't reliably capture
   elements positioned far off-screen (e.g. left: -10000px), so we
   keep it within the viewport and rely on the overlay for hiding. */
.pdf-offscreen {
  position: fixed;
  left: 0;
  top: 0;
  width: 210mm;          /* A4 width */
  background: #fff;
  z-index: 1;
  pointer-events: none;
}
.pdf-offscreen:empty {
  /* When no template content is present, take no visual space. */
  width: 0;
  height: 0;
  overflow: hidden;
}

.pdf-page {
  width: 210mm;
  min-height: 297mm;
  padding: 14mm 16mm 18mm;
  background: #ffffff;
  color: #111;
  font-family: 'Segoe UI', 'Inter', Arial, sans-serif;
  font-size: 9.2pt;
  line-height: 1.55;
  position: relative;
}

.pdf-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12mm;
  margin-bottom: 8mm;
}
.pdf-logo {
  width: 54mm;
  height: auto;
  display: block;
}
.pdf-date-block {
  text-align: right;
  padding-top: 4mm;
}
.pdf-date-label {
  display: block;
  font-size: 8.1pt;
  color: #555;
  margin-bottom: 1mm;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.pdf-date-value {
  display: block;
  font-size: 10.8pt;
  font-weight: 600;
  color: #111;
}

.pdf-divider {
  height: 2px;
  background: linear-gradient(90deg, #2563eb, #e11d48);
  margin: 0 0 7mm 0;
  border-radius: 2px;
}

.pdf-info-row {
  display: flex;
  gap: 10mm;
  margin-bottom: 7mm;
}
.pdf-info-block {
  flex: 1;
  background: #f8f9fc;
  border-left: 3px solid #2563eb;
  padding: 4mm 5mm;
}
.pdf-info-block:last-child {
  border-left-color: #e11d48;
}
.pdf-info-block h3 {
  font-size: 10.35pt;
  font-weight: 700;
  color: #111;
  margin-bottom: 3mm;
}
.pdf-info-block .row {
  display: flex;
  align-items: baseline;
  margin-bottom: 1.2mm;
  font-size: 9.2pt;
}
.pdf-info-block .row .key {
  width: 32mm;
  font-weight: 600;
  color: #333;
}
.pdf-info-block .row .val {
  flex: 1;
  color: #111;
  word-break: break-word;
}
.pdf-info-block .parts-line {
  margin-top: 1.5mm;
  font-size: 8.65pt;
  color: #444;
  line-height: 1.4;
}

.pdf-content {
  font-size: 9.1pt;
  line-height: 1.6;
  color: #1a1a1a;
}
.pdf-content p {
  margin-bottom: 3mm;
  text-align: justify;
}
.pdf-content .greeting {
  font-weight: 600;
  margin-bottom: 1.5mm;
}
.pdf-content ul {
  margin: 2mm 0 4mm 6mm;
  padding: 0;
}
.pdf-content li {
  margin-bottom: 1.8mm;
  list-style: disc;
}

.pdf-footer-bar {
  position: absolute;
  left: 16mm;
  right: 16mm;
  bottom: 8mm;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 7.65pt;
  color: #555;
  padding-top: 3mm;
  border-top: 1px solid #ddd;
}
