/* ============================================================
   KonaConv — Stylesheet
   Dark theme, responsive, production-quality
   ============================================================ */

/* ----- CSS Variables ----- */
:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #1c2a4a;
  --bg-input: #0f1a30;
  --accent: #0f3460;
  --highlight: #e94560;
  --highlight-hover: #ff6b81;
  --text-primary: #e8e8f0;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border: #2a3a5c;
  --border-light: #374868;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --transition: 0.2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --max-width: 780px;
}

/* ----- Reset & Base ----- */
*,
*::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-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ----- Header ----- */
.header {
  padding: 2rem 1.5rem 1rem;
  text-align: center;
}

.header-content {
  max-width: var(--max-width);
  margin: 0 auto;
}

.logo {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  letter-spacing: -0.02em;
}

.logo-icon {
  display: flex;
  align-items: center;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 400;
  margin-top: 0.25rem;
}

/* ----- Main ----- */
.main {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
}

/* ----- Section Titles ----- */
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

/* ----- Drop Zone ----- */
.dropzone {
  position: relative;
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  user-select: none;
}

.dropzone:hover {
  border-color: var(--highlight);
  background: rgba(233, 69, 96, 0.04);
}

.dropzone.dragover {
  border-color: var(--highlight);
  background: rgba(233, 69, 96, 0.08);
  transform: scale(1.01);
}

.dropzone-content {
  pointer-events: none;
}

.dropzone-icon {
  color: var(--text-muted);
  margin-bottom: 1rem;
  transition: color var(--transition);
}

.dropzone:hover .dropzone-icon,
.dropzone.dragover .dropzone-icon {
  color: var(--highlight);
}

.dropzone-text {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.dropzone-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  max-width: 420px;
  margin: 0 auto;
  line-height: 1.5;
}

.file-input {
  display: none;
}

/* ----- File List Section ----- */
.file-list-section {
  display: none;
  margin-top: 1.5rem;
}

.file-list-section.visible {
  display: block;
  animation: fadeSlideIn 0.3s ease;
}

.file-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.file-list-header .section-title {
  margin-bottom: 0;
}

.file-list-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-meta-badge {
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--bg-input);
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-weight: 500;
}

/* ----- File List ----- */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}

.file-list::-webkit-scrollbar {
  width: 6px;
}

.file-list::-webkit-scrollbar-track {
  background: transparent;
}

.file-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: border-color var(--transition), background var(--transition);
  animation: fadeSlideIn 0.25s ease;
}

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

.file-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border-radius: var(--radius-xs);
}

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

.file-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.file-status {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  flex-shrink: 0;
  white-space: nowrap;
}

.file-status.pending {
  color: var(--text-secondary);
  background: var(--bg-input);
}

.file-status.uploading {
  color: var(--warning);
  background: rgba(245, 158, 11, 0.12);
}

.file-status.converting {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.12);
  animation: pulse 1.5s ease infinite;
}

.file-status.done {
  color: var(--success);
  background: var(--success-bg);
}

.file-status.error {
  color: var(--error);
  background: var(--error-bg);
}

.file-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  font-size: 1.1rem;
  line-height: 1;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}

.file-remove:hover {
  color: var(--error);
  background: var(--error-bg);
}

/* ----- Settings Panel ----- */
.settings-panel {
  display: none;
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.settings-panel.visible {
  display: block;
  animation: fadeSlideIn 0.3s ease;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.setting-value {
  font-weight: 700;
  color: var(--highlight);
  font-size: 0.9rem;
  min-width: 2.2em;
  text-align: right;
}

.setting-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.format-info {
  font-size: 0.88rem;
  color: var(--text-primary);
  background: var(--bg-input);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: -0.25rem;
}

/* ----- Custom Range Slider ----- */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-input);
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--highlight);
  cursor: pointer;
  border: 3px solid var(--bg-secondary);
  box-shadow: 0 0 0 2px var(--highlight);
  transition: transform var(--transition);
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--highlight);
  cursor: pointer;
  border: 3px solid var(--bg-secondary);
  box-shadow: 0 0 0 2px var(--highlight);
}

/* ----- Inputs ----- */
.input {
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}

.input:focus {
  border-color: var(--highlight);
}

.input::placeholder {
  color: var(--text-muted);
}

/* Number input — hide spinners on some browsers for cleaner look */
.input[type="number"]::-webkit-inner-spin-button,
.input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
}

/* ----- Select ----- */
.select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

/* ----- Buttons ----- */
.btn {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary {
  background: var(--highlight);
  color: #fff;
  padding: 0.75rem 2rem;
}

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

.btn-convert {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
}

.btn-download {
  background: var(--success);
  color: #fff;
  padding: 0.85rem 2.5rem;
  font-size: 1rem;
  border-radius: var(--radius-sm);
}

.btn-download:hover:not(:disabled) {
  background: #059669;
}

.btn-text {
  background: none;
  color: var(--text-secondary);
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
}

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

.btn-clear:hover {
  color: var(--error);
}

.btn-new {
  margin-top: 0.75rem;
  font-size: 0.88rem;
}

/* ----- Progress Section ----- */
.progress-section {
  display: none;
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-align: center;
}

.progress-section.visible {
  display: block;
  animation: fadeSlideIn 0.3s ease;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.progress-bar-track {
  width: 100%;
  height: 10px;
  background: var(--bg-input);
  border-radius: 5px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--highlight), #ff6b81, var(--highlight));
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
  transition: width 0.4s ease;
}

.progress-status {
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ----- Download Section ----- */
.download-section {
  display: none;
  margin-top: 1.5rem;
  padding: 2rem 1.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-align: center;
}

.download-section.visible {
  display: block;
  animation: fadeSlideIn 0.3s ease;
}

.download-icon {
  margin-bottom: 1rem;
}

.download-section .section-title {
  color: var(--success);
  margin-bottom: 0.75rem;
}

.savings-info {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
}

.savings-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.savings-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.savings-value {
  font-weight: 700;
  font-size: 1.1rem;
}

.savings-value.highlight {
  color: var(--success);
}

/* ----- Error Section ----- */
.error-section {
  display: none;
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: var(--error-bg);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  text-align: center;
}

.error-section.visible {
  display: block;
  animation: fadeSlideIn 0.25s ease;
}

.error-message {
  color: var(--error);
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

/* ----- Footer ----- */
.footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ----- Animations ----- */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

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

/* ----- Responsive ----- */
@media (max-width: 640px) {
  .header {
    padding: 1.5rem 1rem 0.75rem;
  }

  .logo {
    font-size: 1.6rem;
  }

  .subtitle {
    font-size: 0.88rem;
  }

  .main {
    padding: 1rem 1rem 2rem;
  }

  .dropzone {
    padding: 2rem 1.25rem;
  }

  .dropzone-icon svg {
    width: 48px;
    height: 48px;
  }

  .dropzone-text {
    font-size: 1rem;
  }

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

  .file-list-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .savings-info {
    flex-direction: column;
    gap: 0.75rem;
  }

  .btn-download {
    width: 100%;
  }
}

@media (max-width: 400px) {
  .file-item {
    padding: 0.5rem 0.65rem;
    gap: 0.5rem;
  }

  .file-icon {
    width: 30px;
    height: 30px;
    font-size: 1.2rem;
  }

  .file-name {
    font-size: 0.82rem;
  }
}
