/* ===================================
   Global Styles & Reset
   =================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #1a73e8;
  --primary-hover: #1557b0;
  --success-color: #0f9d58;
  --error-color: #d93025;
  --text-color: #202124;
  --text-secondary: #5f6368;
  --border-color: #dadce0;
  --bg-color: #ffffff;
  --bg-secondary: #f8f9fa;
  --shadow-sm: 0 1px 2px 0 rgba(60, 64, 67, 0.3);
  --shadow-md: 0 2px 6px 2px rgba(60, 64, 67, 0.15);
  --radius: 8px;
  --sidebar-width: 200px;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
               "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text-color);
  background-color: var(--bg-secondary);
  line-height: 1.6;
  font-size: 14px;
}

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

a:hover {
  text-decoration: underline;
}

/* ===================================
   Header
   =================================== */
header {
  background: var(--bg-color);
  padding: 24px 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  font-size: 32px;
  display: block;
}

.logo-text {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-color);
}

.header-text {
  flex: 1;
  min-width: 250px;
}

.header-text h1 {
  font-size: 28px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-color);
}

.subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Language Switcher - Dropdown Style */
.lang-switcher {
  position: relative;
  margin-left: auto;
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-color);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.lang-toggle:hover {
  border-color: var(--primary-color);
  background-color: var(--bg-secondary);
}

.lang-toggle .lang-icon {
  font-size: 18px;
}

.lang-toggle .lang-current {
  font-weight: 500;
}

/* Dropdown Menu */
.lang-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  list-style: none;
  padding: 8px 0;
  margin: 0;
  z-index: 1000;
  /* Hidden by default */
  display: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s, transform 0.2s;
}

/* Show menu on hover (desktop) */
.lang-switcher:hover .lang-menu {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Show menu when open class is added (mobile) */
.lang-switcher.open .lang-menu {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.lang-switcher.open .lang-toggle {
  border-color: var(--primary-color);
  background-color: var(--bg-secondary);
}

.lang-menu li {
  margin: 0;
  padding: 0;
}

.lang-menu .lang-link {
  display: block;
  padding: 10px 16px;
  color: var(--text-color);
  text-decoration: none;
  font-size: 14px;
  transition: background-color 0.2s, color 0.2s;
}

.lang-menu .lang-link:hover {
  background-color: var(--bg-secondary);
  color: var(--primary-color);
  text-decoration: none;
}

.lang-menu .lang-link.active {
  background-color: var(--primary-color);
  color: white;
  font-weight: 500;
}

.lang-menu .lang-link.active:hover {
  background-color: var(--primary-hover);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .lang-switcher {
    margin-left: 0;
    margin-top: 12px;
  }

  .lang-toggle {
    width: 100%;
    justify-content: center;
  }

  .lang-menu {
    right: auto;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    min-width: 250px;
  }

  .lang-switcher:hover .lang-menu {
    transform: translateX(-50%) translateY(0);
  }

  .lang-switcher.open .lang-menu {
    transform: translateX(-50%) translateY(0);
  }
}

/* ===================================
   Main Layout
   =================================== */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

.page-layout {
  display: flex;
  justify-content: center;
  gap: 24px;
  align-items: start;
}

/* ===================================
   Middle Content Area
   =================================== */
.tool-and-middle-ad {
  max-width: 960px;
  width: 100%;
  flex-shrink: 1;
}

/* ===================================
   Sidebar Columns
   =================================== */
.sidebar-column {
  position: sticky;
  top: 16px;
  width: var(--sidebar-width);
  flex-shrink: 0;
}

.sidebar-content {
  background: var(--bg-secondary);
  border: 1px dashed #e0e0e0;
  border-radius: var(--radius);
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 12px;
}

.horizontal-section {
  margin: 32px 0;
}

.horizontal-section .sidebar-content {
  min-height: 100px;
}

/* ===================================
   Tool Panel
   =================================== */
.tool-panel {
  background: var(--bg-color);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 24px;
}

.tool-panel h2 {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 16px;
  color: var(--text-color);
}

.tool-panel h3 {
  font-size: 16px;
  font-weight: 500;
  margin: 16px 0 8px;
  color: var(--text-color);
}

/* ===================================
   Step Labels
   =================================== */
.step-label {
  display: inline-block;
  background: var(--primary-color);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  margin-bottom: 8px;
}

.step-description {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ===================================
   Upload Section
   =================================== */
.upload-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--primary-color);
  background: #e8f0fe;
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.upload-main {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-color);
}

.upload-sub {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Compact state after file is loaded */
.upload-area.has-file {
  padding: 16px;
  border-style: solid;
  border-color: var(--border-color);
  background: var(--bg-color);
}

.upload-area.has-file:hover {
  border-color: var(--primary-color);
  background: var(--bg-secondary);
}

.upload-area.has-file .upload-placeholder {
  display: none;
}

.upload-compact {
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  text-align: left;
}

.upload-area.has-file .upload-compact {
  display: flex;
}

.upload-compact-thumb {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.upload-compact-info {
  flex: 1;
  min-width: 0;
}

.upload-compact-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.upload-compact-size {
  font-size: 12px;
  color: var(--text-secondary);
}

.upload-compact-action {
  font-size: 13px;
  color: var(--primary-color);
  font-weight: 500;
  white-space: nowrap;
}

.upload-area.has-file:hover .upload-compact-action {
  text-decoration: underline;
}

.file-info {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

.file-info p {
  margin: 8px 0;
  font-size: 14px;
}

.file-info strong {
  color: var(--text-color);
}

.preview-section {
  margin-top: 16px;
}

.preview-container {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  max-height: 400px;
  overflow: auto;
}

.preview-container img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* ===================================
   Preview Comparison Section
   =================================== */
.preview-comparison {
  background: var(--bg-color);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.preview-comparison h3 {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 16px;
  color: var(--text-color);
  text-align: center;
}

.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.comparison-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.comparison-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.comparison-preview {
  width: 100%;
  max-height: 300px;
  overflow: auto;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.comparison-preview img {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: var(--radius);
}

.comparison-info {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  text-align: center;
}

@media (max-width: 600px) {
  .comparison-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .preview-comparison {
    padding: 16px;
  }
}

/* ===================================
   Settings Section
   =================================== */
.settings-group {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.settings-group legend {
  font-weight: 500;
  padding: 0 8px;
  color: var(--text-color);
}

.size-mode {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
}

.size-mode label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.input-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  color: var(--text-color);
}

input[type="number"],
select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}

input[type="checkbox"],
input[type="radio"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.settings-group label {
  display: block;
  margin: 8px 0;
  cursor: pointer;
}

.settings-group label input[type="radio"] {
  margin-right: 8px;
}

/* ===================================
   Preset Buttons
   =================================== */
.preset-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preset-category {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-label {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 50px;
  margin: 0;
}

.preset-btn {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-color);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.preset-btn:hover {
  border-color: var(--primary-color);
  background: #e8f0fe;
}

.preset-btn.active {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: white;
}

.preset-tip {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border-left: 3px solid var(--primary-color);
}

/* ===================================
   Quality Options
   =================================== */
.quality-hint {
  display: inline-block;
  width: 16px;
  height: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: help;
  vertical-align: middle;
  margin-left: 4px;
}

/* ===================================
   Action Section
   =================================== */
.action-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* ===================================
   Action Buttons
   =================================== */
.action-buttons {
  display: flex;
  gap: 12px;
  margin: 24px 0;
}

.btn {
  flex: 1;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border-color);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-loading {
  display: inline-block;
}

/* ===================================
   Status Message
   =================================== */
.status-message {
  margin: 16px 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  display: none;
}

.status-message.success {
  display: block;
  background: #e6f4ea;
  color: var(--success-color);
  border: 1px solid var(--success-color);
}

.status-message.error {
  display: block;
  background: #fce8e6;
  color: var(--error-color);
  border: 1px solid var(--error-color);
}

.status-message.info {
  display: block;
  background: #e8f0fe;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

/* ===================================
   Result Info & Comparison
   =================================== */
.result-info {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

.result-info h3 {
  margin-bottom: 12px;
  font-size: 16px;
  color: var(--text-color);
}

.size-comparison {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.size-comparison .original-size,
.size-comparison .new-size {
  font-size: 14px;
}

.size-comparison .original-size {
  color: var(--text-secondary);
}

.size-comparison .arrow {
  color: var(--primary-color);
  font-weight: bold;
}

.size-comparison .new-size {
  color: var(--success-color);
  font-weight: 500;
}

/* ===================================
   Privacy Notice
   =================================== */
.privacy-notice {
  background: #e8f0fe;
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  margin-top: 24px;
}

.privacy-notice p {
  font-size: 14px;
  color: var(--text-color);
  margin: 0;
}

/* ===================================
   SEO Section
   =================================== */
.seo-section {
  background: var(--bg-color);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.seo-section article {
  margin-bottom: 32px;
}

.seo-section article:last-child {
  margin-bottom: 0;
}

.seo-section h2 {
  font-size: 24px;
  font-weight: 500;
  margin-bottom: 16px;
  color: var(--text-color);
  line-height: 1.3;
}

.seo-section h3 {
  font-size: 18px;
  font-weight: 500;
  margin: 24px 0 12px;
  color: var(--text-color);
}

.seo-section p {
  margin-bottom: 12px;
  line-height: 1.8;
  max-width: 800px;
}

.seo-section ul,
.seo-section ol {
  margin: 16px 0 16px 24px;
  line-height: 1.8;
}

.seo-section li {
  margin-bottom: 8px;
}

.seo-section details {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
}

.seo-section summary {
  font-weight: 500;
  color: var(--text-color);
  cursor: pointer;
  user-select: none;
}

.seo-section details[open] summary {
  margin-bottom: 12px;
  color: var(--primary-color);
}

.seo-section details p {
  margin-top: 8px;
  color: var(--text-secondary);
}

/* ===================================
   Footer
   =================================== */
footer {
  background: var(--bg-color);
  padding: 24px 16px;
  box-shadow: var(--shadow-sm);
  margin-top: 40px;
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  text-align: center;
}

.footer-content p {
  margin: 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.footer-note {
  font-size: 12px;
}

/* ===================================
   Responsive Design
   =================================== */

/* Tablet */
@media (max-width: 1200px) {
  :root {
    --sidebar-width: 120px;
  }

  .sidebar-content {
    min-height: 400px;
    font-size: 12px;
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .page-layout {
    flex-direction: column;
  }

  .sidebar-column {
    display: none;
  }

  .header-text h1 {
    font-size: 22px;
  }

  .subtitle {
    font-size: 14px;
  }

  .tool-panel {
    padding: 20px;
  }

  .tool-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .action-buttons {
    flex-direction: column;
  }

  .preset-category {
    flex-direction: column;
    align-items: flex-start;
  }

  .preset-label {
    margin-bottom: 4px;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .size-mode {
    flex-direction: column;
    gap: 12px;
  }

  .seo-section {
    padding: 20px;
  }

  .seo-section h2 {
    font-size: 20px;
  }

  .seo-section h3 {
    font-size: 16px;
  }

  .horizontal-section {
    order: -1;
    margin: 0 0 24px 0;
  }

  .horizontal-section .sidebar-content {
    min-height: 100px;
  }
}

/* Small Mobile */
@media (max-width: 480px) {
  .upload-area {
    padding: 32px 16px;
  }

  .upload-icon {
    font-size: 36px;
  }

  .logo-text {
    font-size: 18px;
  }

  .header-text h1 {
    font-size: 18px;
  }
}

/* ===================================
   Utility Classes
   =================================== */
.hidden {
  display: none !important;
}

.loading {
  opacity: 0.6;
  pointer-events: none;
}
