/* ============================================
   Pixelius Base — Reset, Typography, Layout
   ============================================ */

/* Reset */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
    'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }
h4 { font-size: 0.9375rem; }

p { color: var(--text-secondary); }

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s ease;
}
a:hover { opacity: 0.8; }

/* Selection */
::selection {
  background: var(--accent);
  color: var(--text-inverse);
}

/* Scrollbar — thin Apple style */
::-webkit-scrollbar {
  width: 0.375rem;
  height: 0.375rem;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 0.1875rem;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* ============================================
   App Layout
   ============================================ */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  height: 3.25rem;
  min-height: 3.25rem;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: fit-content;
}

.logo {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  user-select: none;
}

.logo-icon {
  width: 1.5rem;
  height: 1.5rem;
}

/* Tab Bar */
.tab-bar {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  background: var(--bg-secondary);
  border-radius: 0.5rem;
  padding: 0.1875rem;
  margin: 0 auto;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 1rem;
  border: none;
  border-radius: 0.375rem;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--queue-item-hover);
}

.tab-btn.active {
  background: var(--tab-active-bg);
  color: var(--tab-active-text);
  font-weight: 600;
}

.tab-btn .tab-icon {
  width: 1rem;
  height: 1rem;
  stroke-width: 2;
}

/* Header Right */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: fit-content;
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 0.375rem;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}
.theme-toggle:hover {
  background: var(--queue-item-hover);
  color: var(--text-primary);
}
.theme-toggle svg {
  width: 1.125rem;
  height: 1.125rem;
}

/* User Section */
.user-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-points {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 1.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.user-points:hover {
  background: var(--accent-bg-hover);
}
.user-points svg {
  width: 0.875rem;
  height: 0.875rem;
}

.user-avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
  position: relative;
}
.user-avatar:hover { opacity: 0.8; }

/* User Dropdown */
.user-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-lg);
  padding: 0.25rem;
  min-width: 10rem;
  z-index: 200;
  display: none;
}
.user-dropdown.show { display: block; }

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.user-dropdown-item:hover {
  background: var(--queue-item-hover);
}
.user-dropdown-item.danger {
  color: var(--error);
}
.user-dropdown-item svg {
  width: 1rem;
  height: 1rem;
}

/* ============================================
   Tab Content
   ============================================ */

.tab-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-pane {
  display: none;
  position: absolute;
  inset: 0;
}

.tab-pane.active {
  display: flex;
}

/* 3-Column Layout (Advanced, Deblur, Refine) */
.layout-3col {
  display: flex;
  width: 100%;
  height: 100%;
}

.panel-left {
  width: 17.5rem;
  min-width: 17.5rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.panel-right {
  width: 20rem;
  min-width: 20rem;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Section headers in panels */
.panel-section {
  padding: 0.75rem 1rem;
}

.panel-section-header {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.panel-section + .panel-section {
  border-top: 1px solid var(--divider);
}

/* Panel scrollable area */
.panel-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ============================================
   Utilities
   ============================================ */

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: 0.25rem; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 0.75rem; }
.gap-lg { gap: 1rem; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }

/* Fade-in animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-0.25rem); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

/* No-flash theme initialization */
.no-transition * {
  transition: none !important;
}
