:root {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: rgba(255, 255, 255, 0.75);
  --text: #0f172a;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.06);
  --accent: #7c3aed;
  --accent-dark: #6d28d9;
  --accent-soft: rgba(124, 58, 237, 0.05);
  --success: #10b981;
  --glow: 0 20px 40px -15px rgba(15, 23, 42, 0.05);
  --card-bg: rgba(15, 23, 42, 0.02);
}

* {
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background: 
    radial-gradient(circle at 10% 20%, rgba(124, 58, 237, 0.05) 0%, transparent 45%),
    radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.04) 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
  max-width: 100%;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 32px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #7c3aed;
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 800;
  line-height: 1.1;
  background: linear-gradient(135deg, #0f172a 0%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 450px) minmax(0, 1fr);
  gap: 24px;
}

.layout:has(> :only-child) {
  display: flex;
  justify-content: center;
}

.layout:has(> :only-child) > .panel {
  width: 100%;
  max-width: 600px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  backdrop-filter: blur(20px);
  box-shadow: var(--glow);
  padding: 30px;
  overflow: hidden;
  min-width: 0;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow: hidden;
  min-width: 0;
}

.drop-zone {
  display: flex;
  min-height: 180px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 2px dashed rgba(124, 58, 237, 0.2);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.4);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--accent);
  background: rgba(124, 58, 237, 0.04);
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.05);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

.drop-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 4px;
  transition: all 0.2s ease;
}

.drop-zone:hover .drop-icon-wrapper {
  transform: scale(1.08);
  background: var(--accent);
  color: #fff;
}

.drop-icon {
  width: 20px;
  height: 20px;
}

.drop-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
}

.drop-subtitle {
  color: var(--muted);
  font-size: 0.85rem;
}

/* File info box */
.settings-box {
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: fadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.primary-action {
  min-height: 48px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.25);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.primary-action:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.35);
  filter: brightness(1.05);
}

.primary-action:active:not(:disabled) {
  transform: translateY(0);
}

.primary-action:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Progress area */
.progress-shell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  animation: fadeIn 0.2s ease-out;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
}

.progress-bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, #06b6d4 100%);
  transition: width 180ms ease;
  box-shadow: 0 0 8px rgba(124, 58, 237, 0.3);
}

@media (max-width: 820px) {
  .app {
    padding: 20px 0;
  }

  .header {
    flex-direction: column;
    align-items: stretch;
  }

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

/* File List and Batch Conversion Styles */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 8px;
}

/* Custom Scrollbar for File List */
.file-list::-webkit-scrollbar {
  width: 6px;
}
.file-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 999px;
}
.file-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 999px;
}
.file-list::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

.file-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.01);
  transition: all 0.2s ease;
  min-width: 0;
  width: 100%;
}

.file-item.is-processing {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-item.is-success {
  border-color: rgba(16, 185, 129, 0.2);
  background: rgba(16, 185, 129, 0.02);
}

.file-item.is-error {
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.02);
}

.file-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  width: 100%;
}

.file-item-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.file-item-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-size {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 2px;
}

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

.remove-file-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.remove-file-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

.file-status-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--muted);
}

.file-item.is-processing .file-status-badge {
  background: var(--accent);
  color: #fff;
}

.file-item.is-success .file-status-badge {
  background: var(--success);
  color: #fff;
}

.file-item.is-error .file-status-badge {
  background: #ef4444;
  color: #fff;
}

.file-item-progress-bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  overflow: hidden;
  display: none;
}

.file-item.is-processing .file-item-progress-bar {
  display: block;
}

.file-item-progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent) 0%, #06b6d4 100%);
  border-radius: inherit;
  transition: width 150ms ease;
}

/* Custom Format Buttons and Bitrate Slider Styling */
.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.format-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.format-btn {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  color: #475569;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.01);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.format-btn:hover {
  background: #f8fafc;
  border-color: rgba(124, 58, 237, 0.3);
  color: var(--accent);
  transform: translateY(-1px);
}

/* Active Format capsule as per screenshot (light lavender bg, dark purple text) */
.format-btn.active {
  background: #ddd6fe;
  border-color: #a78bfa;
  color: #4c1d95;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.15);
  transform: translateY(0);
}

.format-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Bitrate Slider Custom Styling */
.bitrate-label-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#bitrateValue {
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 800;
}

.slider-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  margin: 14px 0 8px 0;
  height: 18px;
}

.slider-dots {
  position: absolute;
  left: 9px;
  right: 9px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 1;
  height: 100%;
}

.slider-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.15);
  box-shadow: 0 0 1px rgba(255, 255, 255, 0.8);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider-dot.active {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(124, 58, 237, 0.8);
  transform: scale(1.3);
}

.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  outline: none;
  margin: 0;
  position: relative;
  z-index: 2;
  transition: all 0.2s ease;
}

.slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  border-radius: 999px;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  margin-top: -6px;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--accent-dark);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.6);
}

.slider:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.slider:disabled::-webkit-slider-thumb {
  background: var(--muted);
  box-shadow: none;
  cursor: not-allowed;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
}

.slider-ticks span {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 700;
}

/* Information Section Styling */
.info-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.info-intro {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 8px 0 0 0;
}

.info-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.01);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.info-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.2);
}

.info-card-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.info-card-content h3 {
  margin: 0 0 6px 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
}

.info-card-content p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
}

/* Footer Styling */
.app-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  color: var(--muted);
}

.app-footer p {
  margin: 0;
  font-size: 0.85rem;
  text-align: left;
}

.app-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  transition: color 0.2s ease;
}

.app-footer a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

/* Site Language Picker (Footer - Bottom Right) */
.site-footer {
  display: flex;
  align-items: center;
}

.site-language-picker {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.site-language-picker svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  fill: none;
  stroke: #4b5563;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.site-language-picker select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfd7df;
  border-radius: 6px;
  background: #f8fafc;
  color: #111827;
  padding: 0 38px 0 18px;
  font: inherit;
  font-size: 1rem;
  font-weight: 850;
  cursor: pointer;
}

.site-language-picker select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

@media (max-width: 640px) {
  .app-footer {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }
  .app-footer p {
    text-align: center;
  }
  .site-footer {
    justify-content: center;
    width: 100%;
  }
}

/* RTL (Right-to-Left) Arabic Support Overrides */
html[dir="rtl"] body {
  text-align: right;
}

html[dir="rtl"] .app-footer p {
  text-align: right;
}

html[dir="rtl"] .site-language-picker select {
  padding: 0 18px 0 38px;
}

html[dir="rtl"] .info-card {
  text-align: right;
}

html[dir="rtl"] .guide-card {
  padding: 18px 50px 18px 18px;
  text-align: right;
}

html[dir="rtl"] .guide-card .card-num {
  left: auto;
  right: 12px;
}

/* Extra responsiveness optimizations for small viewport smartphones */
@media (max-width: 480px) {
  .panel {
    padding: 20px 16px;
  }
  .drop-zone {
    padding: 20px 12px;
  }
  .app-footer p {
    font-size: 0.8rem;
  }
  .site-language-picker {
    min-width: 100%;
  }
}
