/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0f0e17;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #16213e;
  --accent-purple: #7b2ff7;
  --accent-pink: #e94560;
  --accent-green: #00c897;
  --accent-red: #ff4757;
  --accent-yellow: #ffa726;
  --text-primary: #ffffff;
  --text-secondary: #e0e0e0;
  --text-muted: #888;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  min-height: 100dvh;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ===== PIN SCREEN ===== */
#pin-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, rgba(123, 47, 247, 0.15) 0%, var(--bg-primary) 60%);
}

.pin-container {
  width: 100%;
  max-width: 360px;
  padding: 32px 24px;
  text-align: center;
}

.logo-section {
  margin-bottom: 48px;
}

.app-title {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

.app-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 6px;
  letter-spacing: 0.5px;
}

.pin-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pin-form label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: left;
}

.pin-form input {
  width: 100%;
  padding: 16px 20px;
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: 12px;
  background: var(--bg-secondary);
  border: 2px solid rgba(123, 47, 247, 0.2);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.3s ease;
  font-family: 'Inter', monospace;
}

.pin-form input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 20px rgba(123, 47, 247, 0.2);
}

.error-text {
  color: var(--accent-red);
  font-size: 0.85rem;
  min-height: 20px;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.3px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple), #6225c7);
  color: var(--text-primary);
  box-shadow: 0 4px 16px rgba(123, 47, 247, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(123, 47, 247, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-success {
  background: linear-gradient(135deg, var(--accent-green), #00a87d);
  color: var(--text-primary);
  box-shadow: 0 4px 16px rgba(0, 200, 151, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, var(--accent-red), #e03040);
  color: var(--text-primary);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  transition: color 0.3s;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== SCANNER SCREEN ===== */
.scanner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.scanner-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

#scanner-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  min-height: 0;
}

#qr-reader {
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-secondary);
}

/* html5-qrcode overrides */
#qr-reader video {
  border-radius: var(--radius) !important;
}

#qr-reader__scan_region {
  min-height: 280px;
}

#qr-reader__dashboard {
  padding: 10px !important;
}

#qr-reader__dashboard_section_swaplink {
  color: var(--accent-purple) !important;
  text-decoration: none !important;
}

.scan-hint {
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ===== RESULT CARD ===== */
.result-card {
  margin: 16px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: slideUp 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.result-card.hidden {
  display: none;
}

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

.result-status {
  padding: 20px 24px;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.result-status.gecerli {
  background: linear-gradient(135deg, rgba(0, 200, 151, 0.15), rgba(0, 200, 151, 0.05));
  color: var(--accent-green);
  border-bottom: 3px solid var(--accent-green);
}

.result-status.kullanilmis,
.result-status.bugun_kullanildi,
.result-status.gecersiz,
.result-status.iptal {
  background: linear-gradient(135deg, rgba(255, 71, 87, 0.15), rgba(255, 71, 87, 0.05));
  color: var(--accent-red);
  border-bottom: 3px solid var(--accent-red);
}

.result-details {
  padding: 20px 24px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.detail-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.detail-value.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}

.badge-1gun {
  background: rgba(233, 69, 96, 0.15);
  color: var(--accent-pink);
}

.badge-kombine {
  background: rgba(123, 47, 247, 0.15);
  color: var(--accent-purple);
}

.kalan-giris {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent-green);
}

.kalan-giris.son {
  color: var(--accent-yellow);
}

.kalan-giris.bitti {
  color: var(--accent-red);
}

.result-actions {
  padding: 16px 24px;
  display: flex;
  gap: 12px;
}

.result-actions .btn {
  flex: 1;
  padding: 14px;
  font-size: 0.95rem;
}

/* ===== STATS BAR ===== */
.stats-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== LOADING ===== */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  border-top-color: var(--accent-purple);
  animation: spin 0.8s linear infinite;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .pin-form input {
    font-size: 1.3rem;
    letter-spacing: 10px;
  }

  .app-title {
    font-size: 1.8rem;
  }

  #qr-reader__scan_region {
    min-height: 240px;
  }

  .result-status {
    font-size: 1rem;
    padding: 16px 20px;
  }
}

/* ===== FULLSCREEN OVERLAY (sonuç flash) ===== */
.flash-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: flashIn 0.3s ease-out, flashOut 0.3s ease-in 0.7s forwards;
  pointer-events: none;
}

.flash-overlay.success {
  background: rgba(0, 200, 151, 0.2);
}

.flash-overlay.error {
  background: rgba(255, 71, 87, 0.2);
}

.flash-icon {
  font-size: 5rem;
  animation: popIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes flashIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes flashOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes popIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}
