/* ==========================================================================
   B.OCR Web - Layout (App Shell, Header, Navigation, Statusbar, Drawer)
   ========================================================================== */

body {
  display: flex;
  flex-direction: column;
}

/* Header (56px height — user friendly) */
.app-header {
  height: 56px;
  min-height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 50;
  user-select: none;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.app-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 5px;
}

.app-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.app-version {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-subtle);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
}

.header-separator {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.header-page-label {
  font-size: 13px;
  color: var(--text-subtle);
}

.credit-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.credit-badge:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-subtle);
}

/* Breadcrumb & Back Navigation in Header */
.header-breadcrumb-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-back-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-back-home:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.header-breadcrumb .crumb-current {
  color: var(--text);
  font-weight: 700;
}

/* Back to Landing */
.btn-back-landing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}
.btn-back-landing:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}

/* Header Navigation Tabs */
.titlebar-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  margin-left: 6px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.nav-tab:hover:not(.active) {
  color: var(--text);
  background: var(--surface-hover);
}
.nav-tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.nav-tab.active svg {
  color: var(--accent);
}

/* Header Right */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Theme Switcher in Header */
.theme-switcher-wrap {
  position: relative;
}

.btn-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-theme-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border);
}

.theme-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 136px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 1010;
}
.theme-dropdown.open {
  display: flex;
}

.theme-option-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.12s ease;
}
.theme-option-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.theme-option-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
  font-weight: 600;
}

.btn-titlebar-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-titlebar-action:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border);
}

/* Main App Container */
.app-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.app-view {
  flex: 1;
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Two Panel Workstation Layout (Used by OCR, Gabungin, Merge, Split) */
.panel-left {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
}

.panel-right {
  flex: 1;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.control-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Statusbar */
.app-statusbar {
  height: var(--statusbar-height);
  min-height: var(--statusbar-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 40;
  user-select: none;
}

.statusbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.status-orb {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-subtle);
  flex-shrink: 0;
}
.status-orb.status-ready { background: var(--success); }
.status-orb.status-running { background: var(--accent); box-shadow: 0 0 6px rgba(59, 130, 246, 0.6); }
.status-orb.status-error { background: var(--danger); }
.status-orb.status-warning { background: var(--warning); }

.statusbar-text {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.statusbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-statusbar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  cursor: pointer;
}
.btn-statusbar-toggle:hover {
  background: var(--surface-2);
  border-color: var(--border-subtle);
  color: var(--text);
}

.badge-count {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

/* Console Drawer */
.console-drawer {
  position: absolute;
  bottom: var(--statusbar-height);
  left: 0;
  right: 0;
  height: 240px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transform: translateY(100%);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
}
.console-drawer.expanded {
  transform: translateY(0);
}

.console-drawer-header {
  height: 34px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

.console-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
}

.console-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 2px 0;
  line-height: 1.4;
}
.log-time {
  color: var(--text-subtle);
  flex-shrink: 0;
}
.log-badge {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
  flex-shrink: 0;
}
.log-msg {
  color: var(--text);
  word-break: break-all;
}
.log-entry.log-info .log-badge { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.log-entry.log-success .log-badge { background: rgba(34, 197, 94, 0.2); color: #4ade80; }
.log-entry.log-warning .log-badge { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.log-entry.log-error .log-badge { background: rgba(239, 68, 68, 0.2); color: #f87171; }

/* ================================================================
   RESPONSIVE WORKSTATION LAYOUT
   ================================================================ */
@media (max-width: 900px) {
  .app-view {
    flex-direction: column;
    overflow-y: auto;
  }

  .panel-left {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: visible;
  }

  .panel-right {
    width: 100%;
    overflow-y: visible;
    flex: none;
    min-height: 380px;
  }
}

@media (max-width: 640px) {
  .app-header {
    height: 50px;
    min-height: 50px;
    padding: 0 10px;
  }

  .header-page-label,
  .header-separator {
    display: none;
  }

  .btn-titlebar-action span,
  .btn-back-landing span {
    display: none;
  }

  .btn-titlebar-action,
  .btn-back-landing {
    padding: 6px;
  }

  .app-brand {
    gap: 6px;
  }

  .app-title {
    font-size: 13.5px;
  }

  .app-version {
    display: none;
  }
}
