/* =============================================
   TOOLYLAB - STICKY TOP BAR
   Modern, minimal, glassmorphism tasarım
   ============================================= */

/* === TOP BAR CONTAINER === */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  box-sizing: border-box;
  height: calc(56px + env(safe-area-inset-top, 0px));
  z-index: 1200;

  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 0px) var(--spacing-md) 0;
  
  background: rgba(15, 15, 25, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  
  transition: transform 0.3s ease, background 0.3s ease;
}

/* Desktop: reklam alanlarını hesaba kat */
@media (min-width: 1200px) {
  .topbar {
    padding: 0 calc(180px + var(--spacing-lg));
  }
}

/* === LOGO === */
.topbar-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
  padding: 8px 12px;
  margin: -8px -12px;
  border-radius: 8px;
  transition: background 0.2s ease;
}
.topbar-logo img,
.topbar-logo svg {
  height: 24px;
  width: auto;
  opacity: 0.95;
  transition: opacity 0.2s ease;
  pointer-events: none; /* SVG içi tıklamayı engelle, parent'a aktar */
}

.topbar-logo:hover img,
.topbar-logo:hover svg {
  opacity: 1;
}

/* === 3 BÖLÜM: sol (logo) · orta (ayarlar+tam ekran) · sağ (dil+menü) === */
.topbar-left {
  display: flex;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
  justify-content: flex-start;
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

/* === CONTROLS (Sağ taraf: dil + menü) === */
.topbar-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 0;
  justify-content: flex-end;
}

/* === ORTAK BUTON STİLİ === */
.topbar-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  
  background: transparent;
  border: none;
  border-radius: 10px;
  
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  
  transition: all 0.2s ease;
}

.topbar-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.topbar-btn:active {
  transform: scale(0.95);
}

.topbar-btn.active {
  background: rgba(102, 126, 234, 0.2);
  color: white;
}

.topbar-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* === DİL SEÇİCİ === */
.lang-dropdown {
  position: relative;
}

.lang-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 6px;
  height: 40px;
  
  background: transparent;
  border: none;
  border-radius: 8px;
  
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.lang-btn .current-flag {
  width: 30px;
  height: 20px;
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.lang-btn .current-flag svg {
  width: 30px;
  height: 20px;
}

/* Dil menüsü */
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  
  padding: 8px;
  
  background: rgba(20, 20, 35, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  pointer-events: none;
  
  transition: all 0.2s ease;
}

.lang-menu:not([hidden]) {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  margin: 4px 0;
  
  border-radius: 8px;
  text-decoration: none;
  
  transition: all 0.15s ease;
}

.lang-option:first-child {
  margin-top: 0;
}

.lang-option:last-child {
  margin-bottom: 0;
}

.lang-option:hover {
  background: rgba(255, 255, 255, 0.1);
}

.lang-option.active {
  background: var(--gradient-primary);
}

.lang-option .flag-icon {
  width: 36px;
  height: 24px;
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.lang-option .flag-icon svg {
  width: 36px;
  height: 24px;
}

/* === INLINE SVG BAYRAKLAR === */
.flag-svg {
  display: block;
}

/* === BODY PADDING (TopBar için yer aç + iOS güvenli alan) === */
body {
  padding-top: calc(56px + env(safe-area-inset-top, 0px));
}

/* === FULLSCREEN MODE === */
/* Topbar fullscreen'de de görünür kalır */
body.fullscreen .topbar {
  background: rgba(15, 15, 25, 0.6);
}

/* === DRAWER'LAR İÇİN GÜNCELLEME === */
.drawer {
  top: calc(56px + env(safe-area-inset-top, 0px)) !important;
  height: calc(100% - 56px - env(safe-area-inset-top, 0px)) !important;
}

body.fullscreen .drawer {
  top: 0 !important;
  height: 100% !important;
}

/* === RESPONSIVE === */
@media (max-width: 480px) {
  .topbar {
    height: calc(52px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) var(--spacing-sm) 0;
  }
  
  .topbar-logo {
    padding: 6px 10px;
    margin: -6px -10px;
  }

  .topbar-logo img,
  .topbar-logo svg {
    height: 20px;
  }
  
  .topbar-btn {
    width: 36px;
    height: 36px;
  }
  
  .topbar-btn svg {
    width: 18px;
    height: 18px;
  }
  
  .lang-btn {
    height: 36px;
    padding: 0 8px;
  }
  
  .lang-btn .current-flag {
    width: 22px;
    height: 22px;
  }
  
  .lang-btn .current-flag svg {
    width: 22px;
    height: 22px;
  }
  
  body {
    padding-top: calc(52px + env(safe-area-inset-top, 0px));
  }

  .drawer {
    top: calc(52px + env(safe-area-inset-top, 0px)) !important;
    height: calc(100% - 52px - env(safe-area-inset-top, 0px)) !important;
  }
}

/* === TOOL CONTAINER AYARLAMA === */
.tool-container {
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
}

@media (max-width: 480px) {
  .tool-container {
    min-height: calc(100vh - 52px);
    min-height: calc(100dvh - 52px);
  }
}

/* Fullscreen'de topbar görünür kaldığı için yüksekliği düş; sığmayan içerik kaydırılabilir.
   justify-content: safe center → içerik sığıyorsa ortalar, sığmıyorsa üstten hizalar (kırpma yok). */
body.fullscreen .tool-container {
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
  max-height: calc(100vh - 56px);
  max-height: calc(100dvh - 56px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  justify-content: safe center;
}

@media (max-width: 480px) {
  body.fullscreen .tool-container {
    min-height: calc(100vh - 52px);
    min-height: calc(100dvh - 52px);
    max-height: calc(100vh - 52px);
    max-height: calc(100dvh - 52px);
  }
}

/* === ESKİ ELEMENTLERI GİZLE === */
.fixed-controls,
.app-header,
.lang-switcher {
  display: none !important;
}

/* === AYARLAR BUTONU KEŞFEDİLEBİLİRLİK (dönen dişli + tooltip) === */
/* Dişli 1 tam tur döner, sonra ~2.8sn bekler, tekrar eder (stabil ve pürüzsüz) */
@keyframes gearSpin {
  0%   { transform: rotate(0deg); }
  20%  { transform: rotate(360deg); }
  100% { transform: rotate(360deg); }
}

#optionsBtn svg {
  transform-origin: 50% 50%;
  animation: gearSpin 3.5s ease-in-out infinite;
}

/* Kullanıcı ayarları henüz açmadıysa hafif vurgulu arka plan */
.topbar-btn.hint-pulse {
  background: rgba(102, 126, 234, 0.22);
  color: #fff;
}

.options-hint {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  white-space: nowrap;
  padding: 7px 11px;
  border-radius: 9px;
  background: var(--gradient-primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
  z-index: 1300;
}

.options-hint::before {
  content: '';
  position: absolute;
  bottom: 100%;
  right: 13px;
  border: 5px solid transparent;
  border-bottom-color: #667eea;
}

.options-hint.show {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  #optionsBtn svg { animation: none; }
}

/* Kurulu uygulamada (standalone) tam ekran butonu gereksiz — gizle (iOS ipucu çıkmasın) */
@media all and (display-mode: standalone) {
  #fullscreenBtn { display: none !important; }
}
