/* ============================================================================
   Color Variables (shared with zip compare tool)
   ============================================================================ */
:root {
  --primary-purple: #5B5B87;
  --primary-cyan: #00A7E1;
  --light-purple: #7B7BA7;
  --dark-purple: #3B3B67;
  --accent-cyan: #00C4FF;
  --light-cyan: #E6F7FF;
  --success-green: #28a745;
  --warning-yellow: #ffc107;
  --danger-red: #dc3545;
  --light-bg: #F8F9FA;
  --white: #FFFFFF;
  --text-dark: #212529;
  --text-muted: #6c757d;
}

/* ============================================================================
   Bootstrap Overrides
   ============================================================================ */
.btn-primary {
  background-color: var(--primary-cyan);
  border-color: var(--primary-cyan);
  color: var(--white);
  font-weight: 600;
  transition: all 0.3s ease;
}

.btn-primary:hover {
  background-color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 167, 225, 0.3);
}

.btn-primary:disabled {
  background-color: var(--text-muted);
  border-color: var(--text-muted);
  transform: none;
  box-shadow: none;
}

.btn-outline-primary {
  color: var(--primary-cyan);
  border-color: var(--primary-cyan);
  font-weight: 600;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn-outline-primary:hover {
  background-color: var(--primary-cyan);
  border-color: var(--primary-cyan);
  color: var(--white);
}

.text-primary {
  color: var(--primary-purple) !important;
}

.bg-primary {
  background-color: var(--primary-purple) !important;
}

/* ============================================================================
   General Styles
   ============================================================================ */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #f5f7fa;
  min-height: 100vh;
  color: var(--text-dark);
}

h1.display-4 {
  color: var(--primary-purple);
}

/* ============================================================================
   Cards
   ============================================================================ */
.main-card {
  border-radius: 20px;
  background: var(--white);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card {
  border-radius: 15px;
}

/* ============================================================================
   Format Tabs (top navigation)
   ============================================================================ */
.format-tabs {
  border-bottom: 2px solid #dee2e6;
  justify-content: center;
}

.format-tabs .nav-link {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
  margin-bottom: -2px;
}

.format-tabs .nav-link:hover {
  color: var(--primary-cyan);
  border-bottom-color: rgba(0, 167, 225, 0.3);
}

.format-tabs .nav-link.active {
  color: var(--primary-purple);
  background: transparent;
  border: none;
  border-bottom: 3px solid var(--primary-cyan);
}

/* ============================================================================
   Input Method Tabs (Browse Icons / Upload)
   ============================================================================ */
#input-tabs .nav-link {
  color: var(--text-muted);
  font-weight: 500;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  transition: all 0.2s ease;
}

#input-tabs .nav-link.active {
  background-color: var(--primary-purple);
  color: var(--white);
}

#input-tabs .nav-link:not(.active):hover {
  background-color: var(--light-bg);
}

/* ============================================================================
   Icon Browser
   ============================================================================ */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
  padding: 0.25rem;
}

.icon-grid > .text-center {
  grid-column: 1 / -1;
}

.icon-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.25rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  background: var(--light-bg);
  min-height: 80px;
  position: relative;
}

.icon-card:hover {
  background: #e9ecef;
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.icon-card.selected {
  border-color: var(--primary-cyan);
  position: relative;
}

.icon-card.selected::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 167, 225, 0.12);
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
}

.icon-card.selected::after {
  content: "\f26b";
  font-family: "bootstrap-icons";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: var(--primary-cyan);
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 2;
}

.icon-card.loading {
  opacity: 0.5;
  pointer-events: none;
}

.icon-card.loading .icon-display::after {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  margin: 4px auto 0;
  border: 2px solid var(--primary-cyan);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.icon-card .icon-display {
  font-size: 28px;
  color: var(--text-dark);
  margin-bottom: 0.25rem;
  line-height: 1;
}

.icon-card .icon-display .material-symbols-outlined {
  font-size: 28px;
}

.icon-card .icon-display svg {
  width: 28px;
  height: 28px;
}

.icon-card .icon-name {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  padding: 0 2px;
}

.icon-card .library-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--white);
  background: var(--text-muted);
  border-radius: 3px;
  padding: 0 3px;
  line-height: 1.4;
}

.icon-card .library-badge.material {
  background: var(--primary-purple);
}

.icon-card .library-badge.feather {
  background: var(--primary-cyan);
}

/* Library filter button group */
.library-filter .btn {
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

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

#icon-style {
  font-size: 0.85rem;
  min-width: 110px;
}

/* ============================================================================
   File Upload
   ============================================================================ */
.file-upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  background-color: var(--primary-purple);
  color: var(--white);
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 3px dashed rgba(255, 255, 255, 0.3);
  min-height: 160px;
}

.file-upload-area:hover,
.file-upload-area.drag-over {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(91, 91, 135, 0.3);
  border-color: var(--white);
  background-color: var(--light-purple);
}

.file-upload-area.has-files {
  background-color: var(--success-green);
  border-color: var(--white);
}

.file-upload-area i {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.file-upload-area .upload-text {
  font-weight: 600;
  font-size: 1.1rem;
}

.file-upload-area .upload-hint {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-top: 0.25rem;
}

/* ============================================================================
   File List
   ============================================================================ */
.file-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0 0;
}

.file-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--light-bg);
  border-radius: 10px;
  border-left: 4px solid var(--primary-cyan);
}

.file-list-item .file-name {
  font-weight: 500;
  flex: 1;
}

.file-list-item .file-status {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
}

.file-status.ready { color: var(--primary-cyan); }
.file-status.converting { color: var(--warning-yellow); }
.file-status.done { color: var(--success-green); }
.file-status.failed { color: var(--danger-red); }

.file-list-item .btn-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  margin-left: 0.5rem;
  font-size: 1.1rem;
  transition: color 0.2s;
}

.file-list-item .btn-remove:hover {
  color: var(--danger-red);
}

/* ============================================================================
   Color Palette
   ============================================================================ */
.color-palette-section {
  animation: fadeIn 0.4s ease;
}

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

.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.color-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--light-bg);
  border-radius: 10px;
  transition: all 0.2s ease;
}

.color-item:hover {
  background: #e9ecef;
}

.color-swatch-wrapper {
  position: relative;
  flex-shrink: 0;
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid #dee2e6;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.color-swatch:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.color-picker-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.color-hex-input {
  width: 80px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  text-transform: uppercase;
}

.color-hex-input:focus {
  outline: none;
  border-color: var(--primary-cyan);
  box-shadow: 0 0 0 2px rgba(0, 167, 225, 0.2);
}

.color-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ============================================================================
   SVG Preview
   ============================================================================ */
.preview-container {
  background: var(--white);
  border: 1px solid #dee2e6;
  border-radius: 15px;
  padding: 1.5rem;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.preview-container img {
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
}

.preview-tabs .nav-link {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border: none;
  transition: color 0.2s ease;
}

.preview-tabs .nav-link.active {
  color: var(--primary-purple);
  background: transparent;
  border: none;
  border-bottom: 3px solid var(--primary-cyan);
}

/* ============================================================================
   PNG Size Options
   ============================================================================ */
.size-preset {
  border-radius: 20px !important;
  font-weight: 600;
  font-size: 0.8rem;
  min-width: 60px;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.size-preset.active {
  background-color: var(--primary-cyan) !important;
  border-color: var(--primary-cyan) !important;
  color: var(--white) !important;
}

#btn-lock-ratio {
  transition: all 0.2s;
}

#btn-lock-ratio.unlocked {
  opacity: 0.5;
}

/* ============================================================================
   Convert Button
   ============================================================================ */
.convert-section {
  padding: 0.5rem 0;
}

.btn-convert {
  padding: 0.75rem 2.5rem;
  font-size: 1.1rem;
  border-radius: 12px;
}

/* ============================================================================
   Accordion
   ============================================================================ */
.accordion-button:not(.collapsed) {
  background-color: var(--light-cyan);
  color: var(--primary-purple);
  font-weight: 600;
}

.accordion-button:focus {
  box-shadow: none;
  border-color: rgba(0, 167, 225, 0.2);
}

.accordion-button {
  font-weight: 600;
}

/* ============================================================================
   Links
   ============================================================================ */
a {
  color: var(--primary-cyan);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* ============================================================================
   Responsive Design
   ============================================================================ */
@media (max-width: 768px) {
  h1.display-4 {
    font-size: 2rem;
  }

  .format-tabs .nav-link {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }

  .file-upload-area {
    min-height: 120px;
    padding: 1.5rem 1rem;
  }

  .file-upload-area i {
    font-size: 2rem;
  }

  .icon-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    max-height: 300px;
  }

  .color-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .preview-container img {
    max-height: 250px;
  }

  .library-filter .btn {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }
}

@media (max-width: 480px) {
  .format-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .format-tabs .nav-link {
    white-space: nowrap;
    font-size: 0.75rem;
    padding: 0.5rem 0.5rem;
  }
}

/* ============================================================================
   Scrollbar for icon grid
   ============================================================================ */
.icon-grid::-webkit-scrollbar {
  width: 6px;
}

.icon-grid::-webkit-scrollbar-track {
  background: transparent;
}

.icon-grid::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.icon-grid::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* ============================================================================
   Preview Toolbar
   ============================================================================ */
.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 10px;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
}

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

.toolbar-group-stacked {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
}

.toolbar-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.toolbar-divider {
  width: 1px;
  height: 28px;
  background: #dee2e6;
  flex-shrink: 0;
}

/* Tab clipboard button */
.tab-clipboard-btn {
  background: none;
  border: none;
  padding: 2px 5px;
  margin-left: 2px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}

.tab-clipboard-btn:hover {
  opacity: 1;
  color: var(--primary-cyan);
}

.tab-clipboard-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Single-file preview clipboard overlay */
.preview-img-wrap {
  position: relative;
  display: inline-flex;
  width: 100%;
  justify-content: center;
}

.preview-clipboard-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  line-height: 1.4;
}

.preview-img-wrap:hover .preview-clipboard-btn {
  opacity: 1;
}

.preview-clipboard-btn:hover {
  color: var(--primary-cyan);
  border-color: var(--primary-cyan);
}

.preview-clipboard-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
