/* Theme Management - no backend, localStorage only */

.theme-management {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 2.5rem;
  min-height: 100%;
}

/* Page header */
.theme-management-header {
  margin-bottom: 2rem;
  padding: 1.5rem 1.75rem;
  background: var(--theme-card-bg, rgba(255, 255, 255, 0.9));
  border: 1px solid var(--theme-border-color, #e5e5e5);
  border-radius: var(--theme-radius, 0.5rem);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.08));
}

.theme-management-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--theme-text-primary, #4d4d4f);
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.theme-management-subtitle {
  font-size: 0.9375rem;
  color: var(--theme-text-secondary, #4d4d4f);
  margin: 0 0 1.25rem;
  line-height: 1.55;
  opacity: 0.9;
}

.theme-management-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.theme-reset-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-btn-outline {
  background: transparent;
  color: var(--theme-text-primary, #4d4d4f);
  border: 1px solid var(--theme-border-color, #e5e5e5);
}

.theme-btn-outline:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: var(--theme-primary, #f21b23);
}

.theme-btn {
  padding: 0.625rem 1.25rem;
  border-radius: var(--theme-radius, 0.5rem);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast, 0.2s ease);
}

.theme-btn-primary {
  background: var(--theme-primary, #f21b23);
  color: var(--theme-button-primary-text, #fff);
}

.theme-btn-primary:hover {
  background: var(--theme-primary-dark, #d91820);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.12));
}

.theme-btn-secondary {
  background: var(--theme-content-bg, #e5e5e5);
  color: var(--theme-text-primary, #4d4d4f);
  border: 1px solid var(--theme-border-color, #e5e5e5);
}

.theme-btn-secondary:hover {
  background: #d8d8d8;
  border-color: #ccc;
}

.theme-saved-badge {
  font-size: 0.8125rem;
  color: var(--success-color, #4caf50);
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  background: rgba(76, 175, 80, 0.12);
  border-radius: 0.375rem;
}

/* Light / Dark mode edit tabs */
.theme-mode-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0.5rem;
  border-bottom: 2px solid var(--theme-border-color, #e5e5e5);
}

.theme-mode-tab {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--theme-text-secondary, #4d4d4f);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color var(--transition-fast, 0.2s ease), border-color var(--transition-fast, 0.2s ease);
}

.theme-mode-tab:hover {
  color: var(--theme-primary, #f21b23);
}

.theme-mode-tab.active {
  color: var(--theme-primary, #f21b23);
  border-bottom-color: var(--theme-primary, #f21b23);
}

.theme-edit-hint {
  font-size: 0.875rem;
  color: var(--theme-text-muted, #4d4d4f);
  margin: 0 0 1.25rem;
}

/* Primary themes presets */
.theme-presets-section {
  margin-bottom: 0.5rem;
}

.theme-presets-apply-options {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.theme-presets-apply-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--theme-text-primary, #4d4d4f);
}

.theme-radio-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--theme-text-secondary, #4d4d4f);
  cursor: pointer;
}

.theme-radio-label input {
  cursor: pointer;
}

.theme-presets-desc {
  font-size: 0.875rem;
  color: var(--theme-text-secondary, #4d4d4f);
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

.theme-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
}

.theme-preset-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  padding: 1.25rem 1rem;
  background: var(--theme-card-bg, rgba(255, 255, 255, 0.9));
  border: 2px solid var(--theme-border-color, #e5e5e5);
  border-radius: var(--theme-radius, 0.5rem);
  cursor: pointer;
  transition: all var(--transition-fast, 0.2s ease);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--theme-text-primary, #4d4d4f);
}

.theme-preset-card:hover {
  border-color: var(--theme-primary, #f21b23);
  background: rgba(242, 27, 35, 0.06);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md, 0 2px 6px rgba(0, 0, 0, 0.1));
}

.theme-preset-card:active {
  transform: translateY(0);
}

.theme-preset-swatch {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  box-shadow: var(--shadow-sm, 0 2px 6px rgba(0, 0, 0, 0.2));
  flex-shrink: 0;
}

.theme-preset-name {
  text-align: center;
  line-height: 1.2;
}

/* Live preview */
.theme-preview-section {
  margin-bottom: 0.5rem;
}

.theme-preview {
  padding: 0.5rem 0;
}

.theme-preview-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 0.5rem 0;
}

.theme-preview-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.theme-preview-label {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--theme-text-muted, #4d4d4f);
}

.theme-preview-card {
  padding: 1.5rem;
  max-width: 100%;
}

.theme-preview-light {
  background: var(--theme-card-bg, rgba(255, 255, 255, 0.9));
  color: var(--theme-text-primary, #4d4d4f);
}

.theme-preview-dark {
  background: var(--theme-card-bg, #3a3838);
  color: var(--theme-text-primary, #f2f2f7);
}

.theme-preview-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
}

.theme-preview-card p {
  margin: 0 0 1rem;
  font-size: 0.875rem;
}

.theme-preview-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.theme-preview-badge {
  padding: 0.25rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
}

.theme-preview-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.theme-preview-btn {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: transform var(--transition-fast, 0.2s ease);
}

.theme-preview-btn:active {
  transform: scale(0.98);
}

/* Sections */
.theme-sections {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.theme-section {
  background: var(--theme-card-bg, rgba(255, 255, 255, 0.9));
  border: 1px solid var(--theme-border-color, #e5e5e5);
  border-radius: var(--theme-radius, 0.5rem);
  overflow: hidden;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.08));
}

.theme-section-head {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--theme-text-primary, #4d4d4f);
  margin: 0;
  padding: 1rem 1.25rem;
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid var(--theme-border-color, rgba(0, 0, 0, 0.06));
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast, 0.2s ease), color var(--transition-fast, 0.2s ease);
}

.theme-section-head:hover {
  background: rgba(0, 0, 0, 0.04);
}

.theme-section-toggle {
  font-size: 0.7rem;
  opacity: 0.7;
}

.theme-section-open .theme-section-head {
  border-bottom-color: var(--theme-border-color, rgba(0, 0, 0, 0.06));
}

.theme-section-body {
  padding: 1.25rem 1.5rem;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.theme-section label {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--theme-text-primary, #4d4d4f);
}

.theme-section label span {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.9;
}

/* Color row: color picker + hex input side by side */
.theme-color-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.theme-color-row input[type="color"] {
  width: 44px;
  min-width: 44px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--theme-border-color, #e5e5e5);
  border-radius: 0.375rem;
  cursor: pointer;
  background: var(--theme-input-bg, #fff);
}

.theme-color-row input[type="text"] {
  flex: 1;
  min-width: 0;
}

.theme-section input[type="text"],
.theme-section input[type="number"],
.theme-section select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--theme-border-color, #e5e5e5);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--theme-text-primary, #4d4d4f);
  background: var(--theme-input-bg, #fff);
}

.theme-section select {
  cursor: pointer;
  min-height: 2.25rem;
}

.theme-section input[type="text"]:focus,
.theme-section input[type="number"]:focus,
.theme-section select:focus {
  outline: none;
  border-color: var(--theme-primary, #f21b23);
  box-shadow: 0 0 0 2px var(--theme-focus-ring, rgba(242, 27, 35, 0.2));
}

.theme-section input[type="color"] {
  width: 100%;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--theme-border-color, #e5e5e5);
  border-radius: 0.375rem;
  cursor: pointer;
  background: var(--theme-input-bg, #fff);
}

.theme-input-text {
  margin-top: 0;
}

.theme-section label.theme-full-width,
.theme-section .theme-full-width {
  grid-column: 1 / -1;
}

/* Dark mode: match Theme Management section to design */
body.night-mode .theme-management {
  background: #2e2e32;
}

body.night-mode .theme-management-header {
  background: #242428;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.night-mode .theme-management-title {
  color: #ffffff;
}

body.night-mode .theme-management-subtitle {
  color: #cccccc;
  opacity: 1;
}

body.night-mode .theme-btn-secondary {
  background: #1a1a1a;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.15);
}

body.night-mode .theme-btn-secondary:hover {
  background: #252528;
  border-color: rgba(255, 255, 255, 0.25);
}

body.night-mode .theme-btn-primary {
  background: #f21b23;
  color: #ffffff;
}

body.night-mode .theme-btn-primary:hover {
  background: #d91820;
  box-shadow: 0 2px 8px rgba(242, 27, 35, 0.4);
}

body.night-mode .theme-mode-tabs {
  border-bottom-color: rgba(255, 255, 255, 0.15);
}

body.night-mode .theme-mode-tab {
  color: #b0b0b0;
}

body.night-mode .theme-mode-tab:hover {
  color: #ffffff;
}

body.night-mode .theme-mode-tab.active {
  color: #ffffff;
  border-bottom-color: #f21b23;
}

body.night-mode .theme-edit-hint {
  color: #cccccc;
}

body.night-mode .theme-presets-desc {
  color: #cccccc;
}

body.night-mode .theme-section {
  background: #2e2e32;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

body.night-mode .theme-section-head {
  background: rgba(255, 255, 255, 0.04);
  border-bottom-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

body.night-mode .theme-section-head:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.night-mode .theme-section-open .theme-section-head {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

body.night-mode .theme-section label,
body.night-mode .theme-section label span {
  color: #cccccc;
}

body.night-mode .theme-preset-card {
  background: #2e2e32;
  border-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

body.night-mode .theme-preset-card:hover {
  border-color: #f21b23;
  background: rgba(242, 27, 35, 0.12);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.night-mode .theme-section input[type="text"],
body.night-mode .theme-section input[type="number"],
body.night-mode .theme-section select {
  background: #1a1a1a;
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

body.night-mode .theme-section input[type="text"]:focus,
body.night-mode .theme-section input[type="number"]:focus,
body.night-mode .theme-section select:focus {
  border-color: #f21b23;
  box-shadow: 0 0 0 2px rgba(242, 27, 35, 0.3);
}

body.night-mode .theme-color-row input[type="color"] {
  border-color: rgba(255, 255, 255, 0.2);
  background: #1a1a1a;
}

body.night-mode .theme-saved-badge {
  color: #81c784;
  background: rgba(129, 199, 132, 0.15);
}

@media (max-width: 768px) {
  .theme-management {
    padding: 0 1rem 1.5rem;
  }

  .theme-management-header {
    padding: 1.25rem 1rem;
  }

  .theme-management-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .theme-mode-tabs {
    flex-wrap: wrap;
  }

  .theme-preview-dual {
    grid-template-columns: 1fr;
  }

  .theme-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .theme-presets-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .theme-section-body {
    padding: 1rem 1.25rem;
  }
}
