/* ==========================================================================
   Font Compressor — Styles
   Light mode, blue accent, clean and modern
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-raised: #f9fafb;
  --bg-input: #f3f4f6;
  --bg-hover: #e5e7eb;
  --border: #e5e7eb;
  --border-focus: #2563eb;
  --text: #111827;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --transition: 150ms ease;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Container */
.container {
  max-width: 840px;
  margin: 0 auto;
  padding: 48px 24px;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 40px;
}

.header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 6px;
}

.header p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 32px;
}

.tab-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* =====================
   COMPRESS TAB
   ===================== */

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 24px;
  position: relative;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  display: block;
}

.drop-zone-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.drop-zone-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* File list (queued files before compression) */
.file-list {
  margin-bottom: 24px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 0.875rem;
}

.file-item-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 12px;
}

.file-item-size {
  color: var(--text-muted);
  white-space: nowrap;
  margin-right: 12px;
}

.file-item-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 4px;
  line-height: 1;
  transition: color var(--transition);
}

.file-item-remove:hover {
  color: #ef4444;
}

/* Subset info */
.subset-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Compress button */
.compress-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 32px;
}

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

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

/* Results */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.results-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.download-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.download-all-btn:hover {
  background: var(--accent-hover);
}

.result-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 10px;
}

.result-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.result-card-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.result-card-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.result-savings {
  background: var(--success-soft);
  color: var(--success);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.result-preview {
  padding: 16px 0;
  font-size: 1.5rem;
  line-height: 1.4;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-card-actions {
  display: flex;
  justify-content: flex-end;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.dupe-info {
  padding: 8px 0 12px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.download-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Progress bar for individual items */
.result-card-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.result-card-loading .spinner {
  border-color: rgba(37, 99, 235, 0.2);
  border-top-color: var(--accent);
}

/* =====================
   HISTORY TAB
   ===================== */

#historySection {
  margin-top: 40px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.history-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 0.875rem;
  gap: 12px;
}

.history-item-info {
  flex: 1;
  min-width: 0;
}

.history-item-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-item-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.history-badge {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.history-badge-compressed {
  background: var(--success-soft);
  color: var(--success);
}

.history-badge-saved {
  background: var(--accent-soft);
  color: var(--accent);
}

.history-badge-duplicate {
  background: var(--bg-input);
  color: var(--text-muted);
}

/* =====================
   LIBRARY TAB
   ===================== */

.library-controls {
  margin-bottom: 24px;
}

.library-search {
  width: 100%;
  padding: 11px 14px 11px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border-color var(--transition);
}

.library-search:focus {
  outline: none;
  border-color: var(--border-focus);
}

.search-wrapper {
  position: relative;
  margin-bottom: 16px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: calc(50% - 1px);
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1;
  pointer-events: none;
}

/* Category pills */
.category-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.pill {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.pill:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Preview controls */
.preview-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.preview-text-input {
  flex: 1;
  min-width: 200px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  transition: border-color var(--transition);
}

.preview-text-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* Font count */
.font-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Font list (stacked family cards) */
.font-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Family card */
.font-family-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.font-family-header {
  padding: 20px 20px 12px;
}

.font-family-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.font-card-name {
  font-weight: 600;
  font-size: 1rem;
}

.font-card-badge {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.font-card-preview {
  font-size: 1.4rem;
  line-height: 1.4;
  padding: 8px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

/* Variant rows */
.variant-list {
  border-top: 1px solid var(--border);
}

.variant-row {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  gap: 12px;
}

.variant-row:last-child {
  border-bottom: none;
}

.variant-style {
  font-weight: 500;
  flex: 1;
  min-width: 0;
}

.variant-weight {
  color: var(--text-muted);
  font-size: 0.8rem;
  min-width: 36px;
  text-align: right;
}

.variant-size {
  color: var(--text-muted);
  font-size: 0.8rem;
  min-width: 60px;
  text-align: right;
}

.variant-dl {
  padding: 4px 10px;
  font-size: 0.78rem;
}

/* Download all per family */
.font-family-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.download-all-family-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.download-all-family-btn:hover {
  background: var(--accent-hover);
}

.share-font-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.share-font-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  display: block;
}

/* Footer */
.footer {
  text-align: center;
  padding-top: 48px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

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

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 32px 16px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .variant-row {
    gap: 8px;
    padding: 10px 14px;
  }

  .result-card-top {
    flex-direction: column;
    gap: 8px;
  }

}
