/* ============================================================
   Mobilsayim — Tailwind ile çalışan ince stil katmanı.
   Yalnızca Tailwind'in zor yaptığı şeyler burada:
   - body box defaults
   - scanner overlay & video
   - toast / modal animasyonları
   - dropzone state
   ============================================================ */

* { -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body { overscroll-behavior-y: contain; }

input, textarea, select, button {
  font-family: inherit;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* === Toast === */
.toast {
  pointer-events: auto;
  background: rgba(17, 24, 39, 0.95);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  animation: toastIn .22s ease-out;
  max-width: calc(100vw - 32px);
}
.toast.success { background: #10B981; }
.toast.error   { background: #EF4444; }
.toast.warning { background: #F59E0B; color: #1f2937; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* === Modal === */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 16px;
  animation: fadeIn .18s ease-out;
}
.modal {
  background: #fff;
  border-radius: 16px;
  padding: 22px;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  animation: modalIn .22s ease-out;
}
.modal h3 { margin: 0 0 12px; font-size: 18px; font-weight: 700; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }
@keyframes fadeIn  { from { opacity: 0 } to { opacity: 1 } }
@keyframes modalIn {
  from { transform: scale(0.96) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0);     opacity: 1; }
}

/* === Reusable button (modal içinde kullanılıyor) === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  background: #fff;
  color: #111827;
  transition: opacity .12s, transform .08s;
  min-height: 48px;
  text-decoration: none;
  font-family: inherit;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: #4F46E5; color: #fff; border-color: #4F46E5; }
.btn-primary:hover { background: #3730A3; border-color: #3730A3; }
.btn-success { background: #10B981; color: #fff; border-color: #10B981; }
.btn-danger  { background: #EF4444; color: #fff; border-color: #EF4444; }
.btn-ghost   { background: #fff; color: #111827; border-color: #E5E7EB; }
.btn-ghost:hover { background: #F9FAFB; }
.btn-sm { padding: 8px 12px; font-size: 13px; min-height: 36px; }

/* === Forms === */
.form-control {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #E5E7EB;
  font-size: 15px;
  background: #fff;
  color: #111827;
  outline: none;
  min-height: 48px;
  transition: border-color .12s, box-shadow .12s;
  font-family: inherit;
}
.form-control:focus {
  border-color: #6366F1;
  box-shadow: 0 0 0 3px rgba(79,70,229,.18);
}
textarea.form-control { min-height: 80px; resize: vertical; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #6B7280;
  margin-bottom: 6px;
}
.form-group { margin-bottom: 14px; }

/* === Scanner === */
.scanner-area {
  position: relative;
  width: 100%;
  background: #000;
  height: calc(100vh - 60px - 56px - 64px);
  min-height: 320px;
  overflow: hidden;
}
#qr-reader { width: 100%; height: 100%; }
#qr-reader video {
  object-fit: cover !important;
  width: 100% !important;
  height: 100% !important;
}
#qr-reader__dashboard { display: none !important; }
.scanner-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
.scanner-frame {
  position: relative;
  width: 70%;
  max-width: 280px;
  aspect-ratio: 1.4 / 1;
  border: 2px solid rgba(255,255,255,.85);
  border-radius: 12px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,.35);
  overflow: hidden;
}
.scanner-line {
  position: absolute;
  left: 8%; right: 8%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #4F46E5, transparent);
  box-shadow: 0 0 12px rgba(79,70,229,.7);
  animation: scanLine 2.4s ease-in-out infinite;
  border-radius: 2px;
}
@keyframes scanLine {
  0%   { top: 8%;  opacity: .9; }
  50%  { top: 92%; opacity: .9; }
  100% { top: 8%;  opacity: .9; }
}
.scanner-hint {
  position: absolute;
  bottom: 12px; left: 0; right: 0;
  text-align: center;
  color: rgba(255,255,255,.85);
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.scanner-status {
  position: absolute; top: 12px; left: 12px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
}
.scanner-status.paused { background: rgba(245,158,11,.95); color:#1f2937; }

/* === Drop zone === */
.dropzone-active { border-color: #4F46E5 !important; background: rgba(79,70,229,.06) !important; }

/* === Spinner === */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner.dark { border-color: rgba(17,24,39,.2); border-top-color: #4F46E5; }
@keyframes spin { to { transform: rotate(360deg) } }

/* === Login gradient background === */
.login-bg {
  background:
    radial-gradient(circle at 20% 10%, rgba(79,70,229,0.18) 0%, rgba(79,70,229,0) 45%),
    radial-gradient(circle at 80% 90%, rgba(245,158,11,0.18) 0%, rgba(245,158,11,0) 45%),
    linear-gradient(180deg, #F9FAFB 0%, #EEF2FF 100%);
}
.login-card-anim { animation: loginIn .35s ease-out; }
@keyframes loginIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === Active sayım gradient kart === */
.active-sayim-card {
  background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
  color: #fff;
  border-radius: 12px;
}

/* ============================================================
   PWA Standalone — safe area & layout
   ============================================================ */
:root {
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

/* Standalone'da üst topbar status-bar altına padding */
.pwa-standalone .topbar {
  padding-top: var(--safe-top);
  height: calc(60px + var(--safe-top));
}
/* Bottom nav iOS home indicator için */
.pwa-standalone .bottom-nav {
  padding-bottom: var(--safe-bottom);
  height: calc(64px + var(--safe-bottom));
}
/* Standalone'da ana içerik altında bottom nav payı arttı */
.pwa-standalone main:not(.no-bottom) { padding-bottom: calc(80px + var(--safe-bottom)); }

/* Login & forced-change full-screen sayfaları */
.pwa-standalone .login-bg {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* Standalone modunda kamera ekranını tam yayılt */
.pwa-standalone .scanner-area {
  height: calc(100vh - 60px - 56px - 64px - var(--safe-top) - var(--safe-bottom));
}

/* ============================================================
   PWA Install card (Android/iOS)
   ============================================================ */
.pwa-install-card {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left:   calc(16px + var(--safe-left));
  right:  calc(16px + var(--safe-right));
  max-width: 460px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(17,24,39,0.18);
  padding: 14px 14px 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 9999;
  transform: translateY(150%);
  opacity: 0;
  transition: transform .32s cubic-bezier(.2,.7,.3,1), opacity .25s;
}
.pwa-install-card.show { transform: translateY(0); opacity: 1; }
.pwa-install-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4F46E5, #3730A3);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.pwa-install-icon svg, .pwa-install-icon i { width: 22px; height: 22px; }
.pwa-install-content { flex: 1; min-width: 0; }
.pwa-install-title { font-weight: 600; color: #111827; font-size: 14px; line-height: 1.2; }
.pwa-install-text  { font-size: 12px; color: #6B7280; margin-top: 3px; line-height: 1.35; }
.pwa-install-text .inline-icon {
  width: 13px; height: 13px;
  display: inline-block; vertical-align: -2px;
  margin: 0 1px;
}
.pwa-install-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.pwa-btn-install {
  background: #4F46E5; color: #fff;
  padding: 8px 14px; border-radius: 8px;
  font-weight: 600; font-size: 13px;
  border: 0; cursor: pointer;
  font-family: inherit;
}
.pwa-btn-install:hover { background: #3730A3; }
.pwa-btn-dismiss {
  background: transparent; color: #9CA3AF;
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 22px; line-height: 1;
  border: 0; cursor: pointer;
}
.pwa-btn-dismiss:hover { background: #F3F4F6; color: #374151; }

/* Standalone modda install card ASLA gösterilmez */
.pwa-standalone .pwa-install-card { display: none !important; }

/* ============================================================
   Anlık güncelleme animasyonları
   ============================================================ */
@keyframes rowFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.row-fade-in { animation: rowFadeIn .28s ease-out; }

@keyframes flashGreen {
  0%   { background-color: rgba(16, 185, 129, .25); }
  100% { background-color: transparent; }
}
.flash-green { animation: flashGreen 1.2s ease-out; }

/* Counter pop on update */
@keyframes counterPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.counter-pop { animation: counterPop .28s ease-out; }

/* ============================================================
   Sync indicator
   ============================================================ */
.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #F3F4F6;
  color: #374151;
  font-size: 12px;
  font-weight: 500;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  transition: filter .15s;
}
.sync-indicator:hover { filter: brightness(0.96); }
.sync-indicator .sync-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #9CA3AF;
  flex-shrink: 0;
}
.sync-indicator.online  { background: #ECFDF5; color: #065F46; }
.sync-indicator.online  .sync-dot { background: #10B981; }
.sync-indicator.offline { background: #FEF2F2; color: #991B1B; }
.sync-indicator.offline .sync-dot { background: #EF4444; animation: syncPulse 2s infinite; }
.sync-indicator.syncing { background: #FFFBEB; color: #92400E; }
.sync-indicator.syncing .sync-dot { background: #F59E0B; animation: spin 1s linear infinite; }

.sync-badge {
  background: #4F46E5;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
  line-height: 14px;
}
.sync-badge.hidden { display: none; }

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

/* Mobil küçük ekranda label gizle, sadece dot */
@media (max-width: 360px) {
  .sync-indicator .sync-label { display: none; }
}
