/* ============================================================
   IMAGE COMPRESSOR & OPTIMIZER — Core Stylesheet (style.css)
   Conforms strictly to Sections 4, 5, 6, 7 of Specification
   ============================================================ */

:root {
  /* Primary Brand Palette */
  --primary: #4F8DF7;
  --primary-hover: #3D7FEA;
  --primary-active: #326FD5;
  --primary-dark: #2563EB;
  --primary-rgb: 79, 141, 247;
  --primary-light: rgba(79, 141, 247, 0.12);

  /* Light Theme Surfaces & Borders */
  --bg: #F6F7FB;
  --surface: #FFFFFF;
  --surface-secondary: #F1F5F9;
  --border: #E2E8F0;
  --border-focus: #4F8DF7;

  /* Typography & Text Colors */
  --text: #172033;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;

  /* Status Colors */
  --success: #16A34A;
  --success-bg: #DCFCE7;
  --warning: #F59E0B;
  --warning-bg: #FEF3C7;
  --error: #DC2626;
  --error-bg: #FEE2E2;
  --info: #0EA5E9;
  --info-bg: #E0F2FE;

  /* Spacing Scale (Section 6: 8px System) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 40px;
  --space-4xl: 48px;
  --space-5xl: 64px;
  --space-6xl: 80px;

  /* Max Widths & Paddings */
  --max-width: 1200px;
  --max-width-lg: 1280px;
  --content-padding: 32px;

  /* Radii & Shadows */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.04);

  /* Typography Font Stacks */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* Typography Scale (Section 5) */
h1, .h1 {
  font-size: 48px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--text);
}

h2, .h2 {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text);
}

h3, .h3 {
  font-size: 24px;
  font-weight: 650;
  line-height: 1.35;
  color: var(--text);
}

h4, .h4 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}

p, .body-text {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-secondary);
}

small, .text-small {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.text-caption {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

/* Container */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--content-padding);
  padding-right: var(--content-padding);
}

.container-lg {
  max-width: var(--max-width-lg);
}

/* Global Header (Section 7) */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  user-select: none;
  flex-shrink: 0;
}

.brand-logo svg {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.brand-logo-img {
  height: 38px;
  width: auto;
  max-width: 44px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 4px;
}

.brand-text-stacked {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-align: left;
}

.brand-text-stacked .brand-name {
  color: var(--text);
  font-weight: 800;
}

.brand-text-stacked .brand-blue,
.brand-logo span.brand-highlight {
  color: #3b82f6;
  font-weight: 800;
}

.brand-logo span.brand-text {
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* 9-Dot Grid Menu Button */
.tools-grid-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tools-grid-btn:hover {
  background-color: rgba(0, 0, 0, 0.06);
  color: var(--primary);
  border-color: var(--border);
  transform: translateY(-1px);
}

[data-theme="dark"] .tools-grid-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--primary);
}

/* Main Navigation (Image 2 Match - Single Horizontal Line) */
.main-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  cursor: pointer;
  background: none;
  border: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-link:hover, .nav-link:focus-visible {
  color: var(--primary);
  background-color: transparent;
}

.nav-link.active {
  color: var(--primary);
  background-color: transparent;
}

.dropdown-chevron {
  transition: transform var(--transition-fast);
  margin-left: 2px;
}

/* Header Right Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* Dropdown Container */
.dropdown-container {
  position: relative;
}

.dropdown-container.open #more-tools-dropdown-btn {
  color: var(--primary);
}

.dropdown-container.open .dropdown-chevron {
  transform: rotate(180deg);
}

/* 5-Column Mega Menu (Reference Image 2) */
.dropdown-menu.mega-menu {
  position: absolute;
  top: calc(100% + 14px);
  right: -20px;
  width: 960px;
  max-width: 95vw;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px -8px rgba(15, 23, 42, 0.16);
  padding: 24px 28px;
  display: none;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
  z-index: 200;
}

/* Arrow Caret pointing to MORE TOOLS */
.dropdown-menu.mega-menu::before {
  content: '';
  position: absolute;
  top: -7px;
  right: 68px;
  width: 12px;
  height: 12px;
  background-color: var(--surface);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
  z-index: 201;
}

.dropdown-container.open .dropdown-menu.mega-menu {
  display: grid;
  animation: dropdownFadeIn 150ms ease-out forwards;
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.mega-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mega-col-title {
  font-size: 13px;
  font-weight: 700;
  color: #64748B;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-left: 8px;
  user-select: none;
}

[data-theme="dark"] .mega-col-title {
  color: #94A3B8;
}

.mega-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
  text-decoration: none;
  width: 100%;
}

.mega-item:hover, .mega-item:focus-visible {
  background-color: #F0F7FF;
  color: var(--primary);
}

[data-theme="dark"] .mega-item:hover, [data-theme="dark"] .mega-item:focus-visible {
  background-color: #1E293B;
  color: var(--primary);
}

.mega-icon-badge {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mega-icon-badge svg {
  width: 16px;
  height: 16px;
}

/* Badge colors matching Image 3 (Soft tinted background with colored icon) */
.badge-green {
  background-color: #ecfdf5;
  color: #10b981;
}

.badge-purple {
  background-color: #f3e8ff;
  color: #9333ea;
}

.badge-blue {
  background-color: #e0f2fe;
  color: #0284c7;
}

.badge-yellow {
  background-color: #fef9c3;
  color: #ca8a04;
}

.badge-navy {
  background-color: #e0e7ff;
  color: #3b82f6;
}

[data-theme="dark"] .badge-green {
  background-color: rgba(16, 185, 129, 0.18);
  color: #34d399;
}

[data-theme="dark"] .badge-purple {
  background-color: rgba(147, 51, 234, 0.18);
  color: #c084fc;
}

[data-theme="dark"] .badge-blue {
  background-color: rgba(2, 132, 199, 0.18);
  color: #38bdf8;
}

[data-theme="dark"] .badge-yellow {
  background-color: rgba(202, 138, 4, 0.18);
  color: #facc15;
}

[data-theme="dark"] .badge-navy {
  background-color: rgba(59, 130, 246, 0.18);
  color: #818cf8;
}

.mega-item-text {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

/* Mobile Hamburger Toggle */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
  border-radius: var(--radius-sm);
}

.mobile-menu-toggle:focus-visible {
  outline: 2px solid var(--primary);
}

/* Mobile Navigation Drawer (Matches Image 3) */
.mobile-nav-drawer {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100vh !important;
  background-color: #ffffff !important;
  z-index: 999999 !important;
  overflow-y: auto !important;
  padding: 24px 24px 60px 24px !important;
  display: none;
  flex-direction: column !important;
  box-sizing: border-box !important;
  -webkit-overflow-scrolling: touch;
}

[data-theme="dark"] .mobile-nav-drawer {
  background-color: #0f172a !important;
}

.mobile-nav-drawer.open {
  display: flex !important;
}

.mobile-drawer-top {
  display: flex !important;
  justify-content: flex-end !important;
  align-items: center !important;
  width: 100% !important;
  margin-bottom: 24px !important;
}

.mobile-drawer-close {
  background: transparent !important;
  border: none !important;
  cursor: pointer !important;
  color: #1e293b !important;
  padding: 6px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  outline: none !important;
  box-shadow: none !important;
  margin: 0 !important;
}

[data-theme="dark"] .mobile-drawer-close {
  color: #f1f5f9 !important;
}

.mobile-drawer-content {
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
}

.mobile-menu-section {
  display: flex !important;
  flex-direction: column !important;
  margin-bottom: 28px !important;
  width: 100% !important;
}

.mobile-menu-heading {
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #64748b !important;
  letter-spacing: 0.06em !important;
  text-transform: uppercase !important;
  margin-bottom: 12px !important;
  text-align: left !important;
}

.mobile-menu-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 16px !important;
  padding: 10px 0 !important;
  background: transparent !important;
  border: none !important;
  cursor: pointer !important;
  width: 100% !important;
  text-align: left !important;
  text-decoration: none !important;
  outline: none !important;
  box-shadow: none !important;
  font-family: inherit !important;
}

.mobile-menu-item:hover, .mobile-menu-item:active {
  opacity: 0.8;
}

.mobile-menu-text {
  font-size: 15.5px !important;
  font-weight: 600 !important;
  color: #0f172a !important;
  white-space: nowrap !important;
}

[data-theme="dark"] .mobile-menu-text {
  color: #f8fafc !important;
}

/* Unified Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Page Views Container */
.app-view {
  display: none;
  width: 100%;
  animation: fadeIn 200ms ease-out forwards;
}

.app-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero Section (Section 8 & 9) */
.hero-section {
  text-align: center;
  padding: var(--space-5xl) 0 var(--space-3xl);
}

.hero-title {
  max-width: 840px;
  margin: 0 auto var(--space-md);
}

.hero-subtitle {
  max-width: 680px;
  margin: 0 auto var(--space-lg);
  font-size: 18px;
}

.hero-secondary {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: var(--space-2xl);
}

/* Footer (Section 7, 45, 47) */
.site-footer {
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: auto;
  padding: var(--space-4xl) 0 var(--space-2xl);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: var(--space-3xl);
  margin-bottom: var(--space-4xl);
}

.footer-col h5 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text);
  margin-bottom: var(--space-lg);
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.footer-links a {
  font-size: 14px;
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-2xl);
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-muted);
}
