/* =====================================================
   Open Field Studio - Custom Title Bar
   Inspired by Open PDF Studio's titlebar design
   ===================================================== */

/* Layout: body is a flex column with titlebar on top, app below */
html {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  height: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Hidden by default — shown only on desktop Tauri via JS (.tauri-desktop class on body) */
.title-bar {
  background: linear-gradient(to bottom, #44444C 0%, #36363E 100%);
  border-bottom: 1px solid rgba(217, 119, 6, 0.25);
  padding: 0;
  display: none;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  min-height: 32px;
  flex-shrink: 0;
  -webkit-app-region: drag;
  user-select: none;
  cursor: default;
  position: relative;
  z-index: 1001;
}

body.tauri-desktop .title-bar {
  display: flex;
}

/* App toolbar - logo + name row below titlebar, above tabs */
.app-toolbar {
  background: var(--deep-forge, #36363E);
  padding: 8px 16px 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-toolbar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--construction-amber, #D97706);
}

.app-toolbar .logo h1 {
  font-family: var(--font-heading, 'Space Grotesk', sans-serif);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

/* Toolbar right section */
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Theme toggle button */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #FAFAF9;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}

.theme-toggle-btn:hover {
  background: rgba(217, 119, 6, 0.15);
  border-color: rgba(217, 119, 6, 0.4);
}

/* Tab strip - sits between titlebar and content, visually attached */
.tab-strip {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  background: var(--deep-forge, #36363E);
  padding: 0 12px;
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 2px solid var(--construction-amber, #D97706);
}

.tab-strip::-webkit-scrollbar { display: none; }

.tab-strip .nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  background: transparent;
  color: var(--scaffold-gray, #A1A1AA);
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 3px 3px 0 0;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  bottom: -2px;
  border-bottom: 2px solid transparent;
  margin-bottom: 0;
}

.tab-strip .nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.tab-strip .nav-btn.active {
  background: var(--background, #FAFAF9);
  color: var(--text-primary, #36363E);
  border-bottom: 2px solid var(--background, #FAFAF9);
  font-weight: 600;
}

.tab-strip .nav-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Dark theme: active tab matches dark background */
[data-theme="dark"] .tab-strip .nav-btn.active {
  background: var(--background, #1a1a22);
  color: var(--text-primary, #FAFAF9);
  border-bottom-color: var(--background, #1a1a22);
}

/* Hide the old app-header since we replaced it */
.app-header {
  display: none !important;
}

/* App container fills remaining space, no scroll on container itself */
.app-container {
  flex: 1 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}

/* The nav header stays fixed at top, never scrolls */
.app-header {
  flex-shrink: 0 !important;
}

/* Only the main content area scrolls — between tab strip and status bar */
.main-content {
  flex: 1 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

/* Status bar sits outside app-container, as a sibling at bottom */

.title-bar-left {
  display: flex;
  align-items: center;
  gap: 0;
  height: 100%;
  -webkit-app-region: no-drag;
}

.title-bar-icon {
  width: 18px;
  height: 18px;
  margin-left: 10px;
  pointer-events: none;
  user-select: none;
  flex-shrink: 0;
}

.title-bar-icon svg {
  width: 100%;
  height: 100%;
}

/* Quick Access Toolbar */
.quick-access-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
  height: 100%;
}

.quick-access-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  color: #FAFAF9;
  padding: 0;
  transition: background 0.1s;
}

.quick-access-btn:hover {
  background: rgba(217, 119, 6, 0.2);
}

.quick-access-btn:active {
  background: rgba(217, 119, 6, 0.35);
}

.quick-access-btn:disabled {
  color: rgba(250, 250, 249, 0.35);
  cursor: default;
}

.quick-access-btn:disabled:hover {
  background: transparent;
}

.quick-access-btn svg {
  width: 16px;
  height: 16px;
}

.quick-access-separator {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 5px;
}

/* Center: App title */
.title-bar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.title-bar-app-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #FAFAF9;
  letter-spacing: -0.01em;
}

.title-bar-version {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  color: rgba(250, 250, 249, 0.45);
  font-weight: 500;
}

/* Window Controls */
.window-controls {
  display: flex;
  -webkit-app-region: no-drag;
  height: 100%;
}

.window-btn {
  width: 46px;
  height: 32px;
  border: none;
  background: transparent;
  color: #FAFAF9;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.1s;
}

.window-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.window-btn-close:hover {
  background: #e81123;
  color: white;
}

.window-btn svg {
  pointer-events: none;
}

/* Language dropdown in titlebar */
.tb-lang-dropdown {
  position: relative;
  -webkit-app-region: no-drag;
  margin-right: 2px;
}

.tb-lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #FAFAF9;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  height: 24px;
  transition: all 0.15s;
}

.tb-lang-toggle:hover {
  background: rgba(217, 119, 6, 0.15);
  border-color: rgba(217, 119, 6, 0.4);
}

.tb-lang-toggle.open {
  background: rgba(217, 119, 6, 0.2);
  border-color: rgba(217, 119, 6, 0.5);
}

.tb-lang-toggle svg:first-child {
  opacity: 0.7;
}

.tb-lang-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #2A2A32;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 4px;
  min-width: 150px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  animation: tb-menu-in 0.15s ease;
}

.tb-lang-menu.open {
  display: block;
}

@keyframes tb-menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.tb-lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: none;
  color: rgba(250, 250, 249, 0.8);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  transition: all 0.1s;
}

.tb-lang-option:hover {
  background: rgba(217, 119, 6, 0.15);
  color: #FAFAF9;
}

.tb-lang-option.active {
  background: rgba(217, 119, 6, 0.2);
  color: #D97706;
}

.tb-lang-code {
  font-weight: 700;
  font-size: 11px;
  min-width: 20px;
  color: inherit;
}

/* =====================================================
   RESPONSIVE - Mobile
   ===================================================== */

/* =====================================================
   STATUS BAR
   ===================================================== */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 24px;
  min-height: 24px;
  flex-shrink: 0;
  background: var(--deep-forge, #36363E);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0 12px;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 11px;
  color: rgba(250, 250, 249, 0.6);
  user-select: none;
}

.status-bar-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-bar-sep {
  color: rgba(255, 255, 255, 0.15);
  font-size: 10px;
}

.status-bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

#sb-project {
  font-weight: 600;
  color: rgba(250, 250, 249, 0.8);
  max-width: 200px;
}

/* Dark theme status bar */
[data-theme="dark"] .status-bar {
  background: #141418;
  border-top-color: rgba(255, 255, 255, 0.05);
}

/* =====================================================
   RESPONSIVE - Tablet
   ===================================================== */
@media (max-width: 768px) {
  .app-toolbar {
    padding: 6px 12px 2px;
  }

  .app-toolbar .logo h1 {
    font-size: 1rem;
  }

  .app-toolbar .logo svg {
    width: 22px;
    height: 22px;
  }

  /* Larger touch targets for language dropdown */
  .tb-lang-toggle {
    height: 32px;
    padding: 4px 10px 4px 8px;
    font-size: 12px;
  }

  .tb-lang-option {
    padding: 10px 12px;
    font-size: 14px;
  }

  /* Tab strip: compact, scrollable */
  .tab-strip {
    padding: 0 8px;
    gap: 1px;
  }

  .tab-strip .nav-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
    gap: 4px;
  }

  .tab-strip .nav-btn svg {
    width: 14px;
    height: 14px;
  }

  .main-content {
    padding: 12px !important;
  }

  /* Hide status bar on small screens */
  .status-bar {
    display: none;
  }
}

/* =====================================================
   RESPONSIVE - Mobile / Phone
   ===================================================== */
@media (max-width: 480px) {
  .app-toolbar .logo h1 {
    font-size: 0.9rem;
  }

  .tab-strip .nav-btn svg {
    display: none;
  }

  .tab-strip .nav-btn {
    padding: 6px 8px;
    font-size: 0.72rem;
  }

  .main-content {
    padding: 8px !important;
  }
}

/* =====================================================
   Platform: Web browser
   ===================================================== */
body.platform-web .title-bar {
  display: none;
}

/* =====================================================
   Platform: Android / Mobile Tauri
   ===================================================== */
body.tauri-mobile .title-bar {
  display: none;
}

/* Android safe area (notch / status bar) */
body.tauri-mobile .app-toolbar {
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
}

body.tauri-mobile .main-content {
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
}
