/* ============================================
   VARIABLES & RESET
   ============================================ */
:root {
  /* Dark theme (default) */
  --bg-primary: #0a0b0e;
  --bg-secondary: #13151a;
  --bg-tertiary: #1a1d24;
  --bg-hover: #22252d;
  
  --text-primary: #ffffff;
  --text-secondary: #a8b2c7;
  --text-muted: #6b7280;
  
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: rgba(59, 130, 246, 0.1);
  
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  
  --border: #2a2d36;
  --border-light: #363942;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  
  /* Transitions */
  --transition: all 0.2s ease;
  --transition-slow: all 0.3s ease;
}

/* Light theme */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --bg-hover: #e5e7eb;
  
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: rgba(59, 130, 246, 0.1);
  
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  
  --border: #d1d5db;
  --border-light: #e5e7eb;
}

/* Auto-detect system preference */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-hover: #e5e7eb;
    
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: rgba(59, 130, 246, 0.1);
    
    --border: #e5e7eb;
    --border-light: #d1d5db;
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  font-size: 15px;
}

/* ============================================
   APP LAYOUT
   ============================================ */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: 0;
}

.logo {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.lang-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 1.2rem;
  line-height: 1;
  min-width: 40px;
  height: 32px;
}

.lang-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.lang-toggle:active {
  transform: scale(0.95);
}

.lang-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lang-flag img {
  height: 20px;
  width: auto;
  border-radius: 3px;
}

.lang-flag.hidden {
  display: none;
}

.theme-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  height: 32px;
  width: 32px;
  color: var(--text-secondary);
}

.theme-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-icon {
  display: inline-block;
  line-height: 1;
}

.theme-icon.hidden {
  display: none;
}

.history-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  text-decoration: none;
  height: 32px;
}

.history-toggle:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.history-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.version {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
}

.app-main {
  flex: 1;
  padding: var(--space-xl);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.app-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: var(--space-md) var(--space-lg);
  text-align: center;
}

.support-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ============================================
   UPLOAD ZONE
   ============================================ */
.upload-zone {
  background: var(--bg-secondary);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  text-align: center;
  margin-bottom: var(--space-xl);
  position: relative;
  transition: var(--transition);
}

.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-zone.has-file {
  padding: var(--space-lg);
}

.file-input {
  display: none;
}

.upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  cursor: pointer;
}

.upload-icon {
  color: var(--text-muted);
  transition: var(--transition);
}

.upload-label:hover .upload-icon {
  color: var(--accent);
  transform: translateY(-2px);
}

.upload-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.upload-text strong {
  color: var(--text-primary);
  font-size: 1.1rem;
}

.upload-text small {
  color: var(--text-secondary);
}

.formats {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  padding: var(--space-md);
  border-radius: var(--radius-md);
}

.file-name {
  font-weight: 500;
}

.btn-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-remove:hover {
  background: var(--error);
  color: white;
}

/* ============================================
   CONFIG PANEL - NEW DESIGN
   ============================================ */
.config-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.config-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.config-section.collapsed .section-content {
  display: none;
}

.section-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.section-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.section-header.collapsible {
  width: 100%;
  background: transparent;
  border: none;
  padding: var(--space-lg);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}

.section-header.collapsible:hover {
  background: var(--bg-tertiary);
}

.collapse-icon {
  transition: var(--transition);
  color: var(--text-secondary);
}

.config-section.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.section-content {
  padding: var(--space-lg);
}

/* Preset Grid */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-md);
  padding: var(--space-lg);
}

.preset-card {
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  text-align: center;
}

.preset-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.preset-card.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.preset-card.active .preset-name {
  color: white;
}

.preset-card.active .preset-sizes {
  color: rgba(255, 255, 255, 0.9);
}

.preset-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preset-icon svg {
  width: 100%;
  height: 100%;
}

.preset-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preset-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.preset-sizes {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Labels et textes */
label {
  color: var(--text-primary);
}

.option-label {
  color: var(--text-primary);
}

.section-header h3 {
  color: var(--text-primary);
}

.selected-label {
  color: var(--text-secondary);
}

#selectedPresetName {
  color: var(--text-primary);
  font-weight: 600;
}

/* Custom Templates Section */
.custom-templates-section {
  padding: 0 var(--space-lg) var(--space-lg);
}

.templates-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.templates-header h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0;
}

.templates-list {
  display: grid;
  gap: var(--space-sm);
}

.template-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.template-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.template-item.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.template-info {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.template-name {
  font-weight: 500;
}

.template-sizes-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.template-item.active .template-sizes-count {
  color: rgba(255, 255, 255, 0.9);
}

.template-delete {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.template-delete:hover {
  background: var(--error);
  color: white;
}

/* Custom Input Section */
.custom-input-section {
  padding: 0 var(--space-lg) var(--space-lg);
}

.custom-input-section label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.custom-input-section input {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
}

.custom-input-section small {
  display: block;
  margin-top: var(--space-xs);
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Selected Preset Info */
.selected-preset-info {
  padding: var(--space-md) var(--space-lg);
  background: var(--accent-light);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.selected-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

#selectedPresetName {
  font-weight: 600;
  color: var(--accent);
}

/* Toggle Group */
.toggle-group {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.toggle-btn {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-size: 0.875rem;
}

.toggle-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.toggle-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.toggle-btn svg {
  width: 16px;
  height: 16px;
}

/* Color Picker Row */
.color-picker-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

#bgColor {
  width: 48px;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

#bgHex {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: monospace;
}

/* Sizes List Compact */
.sizes-list.compact {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.size-button {
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  min-width: 60px;
}

.size-button:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.size-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.size-button.active:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.size-button:active {
  transform: scale(0.98);
}

.config-group {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.config-group h3 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.group-header h3 {
  margin-bottom: 0;
}

.group-actions {
  display: flex;
  gap: var(--space-sm);
}

.preset-select {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
}

.preset-select:hover,
.preset-select:focus {
  border-color: var(--accent);
  outline: none;
}

.custom-sizes {
  margin-top: var(--space-md);
}

.custom-sizes input {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.custom-sizes small {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ============================================
   SIZES GRID
   ============================================ */
.sizes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: var(--space-sm);
  margin: var(--space-md) 0;
}

.size-chip {
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.size-chip:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.size-chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.size-chip button {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--error);
  color: white;
  border: 2px solid var(--bg-secondary);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.size-chip:hover button {
  display: flex;
}

/* ============================================
   ADVANCED OPTIONS
   ============================================ */
.advanced-options summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.advanced-options summary::-webkit-details-marker {
  display: none;
}

.advanced-options summary h3 {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

.advanced-options summary h3::before {
  content: '▶';
  font-size: 0.75rem;
  transition: var(--transition);
}

.advanced-options[open] summary h3::before {
  transform: rotate(90deg);
}

.option-group {
  margin-top: var(--space-lg);
}

.option-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.option-buttons {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.radio-group {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.radio-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.radio-label input[type="radio"] {
  accent-color: var(--accent);
}

.bg-controls {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-md);
  align-items: center;
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.slider-group {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.slider-group label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.slider-group input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  padding: var(--space-md) var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

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

.btn-secondary {
  background: var(--bg-secondary);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.875rem;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

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

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

.btn-text {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
}

.btn-text:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.btn-text.primary {
  color: var(--accent);
}

.btn-text.primary:hover {
  background: var(--accent-light);
}

/* ============================================
   ACTIONS BAR
   ============================================ */
.actions-bar {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.export-actions {
  display: flex;
  gap: var(--space-md);
  margin-left: auto;
}

/* ============================================
   STATUS MESSAGE
   ============================================ */
.status-message {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  text-align: center;
  font-weight: 500;
}

.status-message.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-message.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-message.info {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ============================================
   RESULTS SECTION
   ============================================ */
.results-section h2 {
  font-size: 1.25rem;
  margin-bottom: var(--space-lg);
}

.icons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-md);
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.card header {
  padding: var(--space-md);
  background: var(--bg-tertiary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card .label {
  font-weight: 600;
  color: var(--text-primary);
}

.card .thumb {
  padding: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  background-image: 
    linear-gradient(45deg, var(--bg-tertiary) 25%, transparent 25%),
    linear-gradient(-45deg, var(--bg-tertiary) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--bg-tertiary) 75%),
    linear-gradient(-45deg, transparent 75%, var(--bg-tertiary) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.card canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

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

/* ============================================
   HISTORY SECTION
   ============================================ */
.history-section {
  margin-top: var(--space-xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--border);
}

.history-section:empty {
  display: none;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.history-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.history-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  transition: var(--transition);
}

.history-item:hover {
  border-color: var(--border-light);
}

.history-item-thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.history-item-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.history-item-info {
  flex: 1;
}

.history-item-name {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.history-item-meta {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.history-item-actions {
  display: flex;
  gap: var(--space-sm);
}

.history-empty {
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-secondary);
}

/* ============================================
   MODAL
   ============================================ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-primary);
}

.form-group small {
  display: block;
  margin-top: var(--space-xs);
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.suggested-sizes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.size-suggestion {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
}

.size-suggestion:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ============================================
   DROPDOWN MENU
   ============================================ */
.dropdown-container {
  position: relative;
}

.dropdown-trigger {
  position: relative;
  padding-right: var(--space-xl);
}

.dropdown-arrow {
  position: absolute;
  right: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  transition: var(--transition);
  pointer-events: none;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  min-width: 220px;
  z-index: 100;
  padding: var(--space-sm);
}

.dropdown-header {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-sm);
}

.dropdown-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.dropdown-option:hover {
  background: var(--bg-tertiary);
}

.dropdown-option input[type="checkbox"] {
  accent-color: var(--accent);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-sm) 0;
}

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

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

.row {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .app-main {
    padding: var(--space-lg);
  }
  
  .config-panel {
    gap: var(--space-md);
  }
  
  .actions-bar {
    flex-direction: column;
  }
  
  .export-actions {
    margin-left: 0;
    width: 100%;
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .sizes-grid {
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  }
  
  .icons-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}