/* =========================================================
   OFS TLAXCALA - HERRAMIENTAS
   Autor: Omar Gabriel Salvatierra García
   Estilo institucional refinado, moderno y sobrio
   ========================================================= */

/* ===== VARIABLES ===== */
:root {
  --font-sans: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Georgia", "Times New Roman", serif;
  --color-primary: #1e3a8a;
  --color-primary-light: #2563eb;
  --color-accent: #1d4ed8;
  --color-bg: #f6f7fb;
  --color-bg-alt: #eaf2ff;
  --color-glow: rgba(59, 130, 246, 0.12);
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-muted: #64748b;
  --color-border: #e2e8f0;
  --color-soft: rgba(37, 99, 235, 0.08);
  --color-strong: rgba(37, 99, 235, 0.18);
  --color-success: #15803d;
  --color-warning: #b45309;
  --color-error: #b91c1c;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.08);
  --transition: all 0.25s ease;
}

:root[data-theme="dark"] {
  --color-primary: #93c5fd;
  --color-primary-light: #60a5fa;
  --color-accent: #60a5fa;
  --color-bg: #0f172a;
  --color-bg-alt: #111c33;
  --color-glow: rgba(96, 165, 250, 0.16);
  --color-surface: #1e293b;
  --color-text: #e2e8f0;
  --color-muted: #cbd5e1;
  --color-border: #334155;
  --color-soft: rgba(96, 165, 250, 0.16);
  --color-strong: rgba(96, 165, 250, 0.3);
  --color-success: #34d399;
  --color-warning: #facc15;
  --color-error: #f87171;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
}

/* ===== RESET ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: linear-gradient(135deg, var(--color-bg), var(--color-bg-alt));
  color: var(--color-text);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, var(--color-glow), transparent 45%),
    radial-gradient(circle at 85% 10%, rgba(14, 116, 144, 0.08), transparent 50%),
    radial-gradient(circle at 80% 85%, rgba(14, 116, 144, 0.1), transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* =========================================================
   ICONOS LOCALES (SIN CDN)
   ========================================================= */
.fas,
.far,
.fa {
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  font-style: normal;
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.fa-adjust::before { content: "🌓"; }
.fa-home::before { content: "🏠"; }
.fa-file-code::before { content: "📄"; }
.fa-file-invoice-dollar::before { content: "🧾"; }
.fa-folder-tree::before { content: "🗂️"; }
.fa-check-circle::before { content: "✅"; }
.fa-toolbox::before { content: "🧰"; }
.fa-file-upload::before { content: "📤"; }
.fa-cogs::before { content: "⚙️"; }
.fa-download::before { content: "⬇️"; }
.fa-arrow-left::before { content: "⬅️"; }
.fa-exclamation-circle::before { content: "⚠️"; }
.fa-info-circle::before { content: "ℹ️"; }
.fa-exclamation-triangle::before { content: "⚠️"; }
.fa-bug::before { content: "🧩"; }
.fa-chart-bar::before { content: "📊"; }
.fa-ellipsis-h::before { content: "⋯"; }
.fa-trash::before { content: "🗑️"; }
.fa-times::before { content: "✖️"; }

/* =========================================================
   HEADER
   ========================================================= */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 2rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  gap: 1rem;
  flex-wrap: wrap;
}

.ofs-logo {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-weight: 700;
  user-select: none;
}

.logo-text {
  font-size: 1.8rem;
  color: var(--color-primary);
  letter-spacing: -0.5px;
  font-weight: 800;
}

.logo-subtext {
  font-size: 1.2rem;
  color: var(--color-primary-light);
  font-weight: 600;
  letter-spacing: 0.3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-toggle {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.45rem 0.7rem 0.45rem 0.6rem;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  isolation: isolate;
}

.btn-toggle:hover {
  background: var(--color-primary);
  color: #fff;
}

.theme-toggle {
  position: relative;
  overflow: hidden;
  min-width: 190px;
}

.theme-toggle .theme-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border-radius: 999px;
  padding: 0.35rem;
  width: 2rem;
  height: 2rem;
  color: var(--color-primary);
  border: 1px solid var(--color-border);
  transition: transform 0.3s ease, background 0.3s ease, color 0.3s ease;
}

.theme-toggle .theme-label {
  font-weight: 600;
  letter-spacing: 0.2px;
}

.theme-toggle .theme-state {
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.theme-toggle .theme-state-dark {
  background: var(--color-accent);
}

:root[data-theme="light"] .theme-toggle .theme-state-dark,
:root[data-theme="dark"] .theme-toggle .theme-state-light {
  display: none;
}

.btn-toggle:hover .theme-icon {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-color: transparent;
}

.theme-toggle::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 999px;
  background: linear-gradient(120deg, var(--color-soft), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}

.theme-toggle:hover::after {
  opacity: 1;
}

.theme-toggle.is-dark .theme-icon {
  transform: rotate(-20deg) scale(1.05);
  background: var(--color-primary);
  color: #0b1220;
  border-color: transparent;
}

.theme-toggle.is-dark {
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.2);
}

.btn-back {
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius);
  padding: 0.55rem 0.85rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.btn-back:hover {
  background: var(--color-primary-light);
  color: #fff;
}

.primary-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1.4rem;
  margin: 0.6rem 2rem 0;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
}

:root[data-theme="dark"] .primary-nav {
  background: rgba(30, 41, 59, 0.6);
}

.primary-nav .nav-title {
  font-weight: 600;
  color: var(--color-muted);
  letter-spacing: 0.04em;
  font-size: 0.78rem;
}

.primary-nav .nav-links {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.primary-nav .nav-link {
  text-decoration: none;
  color: var(--color-text);
  background: transparent;
  border: 1px solid transparent;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  font-weight: 600;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.primary-nav .nav-link:hover,
.primary-nav .nav-link.is-active {
  background: var(--color-primary);
  color: #fff;
  border-color: transparent;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info .avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--color-primary-light);
  object-fit: cover;
}

.user-info h1 {
  font-size: 1.1rem;
  color: var(--color-primary);
  font-weight: 700;
  text-align: right;
}

h1, h2, h3 {
  font-family: var(--font-display);
  letter-spacing: 0.2px;
}

.user-info p {
  font-size: 0.85rem;
  color: var(--color-muted);
  text-align: right;
}

/* =========================================================
   MAIN / DASHBOARD
   ========================================================= */
.dashboard-main {
  flex: 1; /* ocupa el espacio restante */
  padding: 2.5rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.dashboard-main h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dashboard-description {
  font-size: 1rem;
  color: var(--color-muted);
  margin-bottom: 2rem;
  max-width: 850px;
  line-height: 1.6;
}

/* =========================================================
   GRID DE HERRAMIENTAS
   ========================================================= */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.tool-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
}

.tool-card:hover {
  border-color: var(--color-primary-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.tool-card i {
  font-size: 2.4rem;
  color: var(--color-primary-light);
  margin-bottom: 1rem;
}

.tool-card h3 {
  font-size: 1.15rem;
  color: var(--color-text);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.tool-card p {
  font-size: 0.9rem;
  color: var(--color-muted);
  line-height: 1.4;
}

/* =========================================================
   FORMULARIOS / UPLOADS
   ========================================================= */
.tool-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.tool-section::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(37, 99, 235, 0.08);
  pointer-events: none;
}

.tool-instructions {
  margin-bottom: 1.5rem;
}

form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Estilo de entrada de archivos elegante */
input[type="file"] {
  position: relative;
  appearance: none;
  width: 100%;
  padding: 1.2rem;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-muted);
  font-size: 0.95rem;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-right: 1rem;
}

input[type="file"]::file-selector-button:hover {
  background: var(--color-primary-light);
}

input[type="file"]:hover {
  border-color: var(--color-primary-light);
  background: rgba(37, 99, 235, 0.05);
  color: var(--color-text);
}

/* Upload mejorado para múltiples archivos */
.file-upload {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

.file-upload-label {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
  transition: var(--transition);
  color: var(--color-muted);
}

.file-upload-icon {
  font-size: 2rem;
  color: var(--color-primary-light);
}

.file-upload-title {
  font-weight: 700;
  color: var(--color-text);
}

.file-upload-subtitle {
  font-size: 0.9rem;
  color: var(--color-muted);
}

.file-upload-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.file-upload-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--color-muted);
}

.file-upload-clear {
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}

.file-upload-clear:hover {
  border-color: var(--color-primary-light);
  color: var(--color-primary);
}

.file-upload.drag-active .file-upload-label {
  border-color: var(--color-primary-light);
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
  transform: translateY(-1px);
}

.file-upload.has-files .file-upload-label {
  border-color: var(--color-primary-light);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(15, 23, 42, 0.02));
}

.file-upload.has-files .file-upload-title {
  color: var(--color-primary);
}

.file-upload-progress {
  margin-top: 0.75rem;
  background: var(--color-bg);
  border-radius: 999px;
  border: 1px solid var(--color-border);
  overflow: hidden;
  height: 12px;
  position: relative;
}

.file-upload-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary-light), var(--color-accent));
  transition: width 0.35s ease;
}

.file-upload-progress-label {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: var(--color-muted);
  text-align: right;
}

.file-upload-hint {
  margin-top: 0.35rem;
}

.form-note {
  font-size: 0.9rem;
  color: var(--color-muted);
  background: rgba(37, 99, 235, 0.04);
  border-left: 3px solid var(--color-primary-light);
  padding: 0.8rem 1rem;
  border-radius: 6px;
  line-height: 1.5;
}

/* =========================================================
   BOTONES
   ========================================================= */
.btn-process {
  background: var(--color-accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 0.95rem 1.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  width: fit-content;
  letter-spacing: 0.3px;
}

.btn-process:hover {
  background: var(--color-primary);
  transform: translateY(-1px);
}

button,
.btn-process,
.btn-download,
.btn-secondary,
.btn-back,
.btn-toggle,
.file-upload-clear,
.file-preview-remove,
.toast-close {
  font-family: var(--font-sans);
}

/* =========================================================
   ALERTAS / MENSAJES
   ========================================================= */
.alert {
  padding: 1rem;
  border-radius: var(--radius);
  border-left: 4px solid transparent;
  margin: 1rem 0;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.95rem;
}

.alert i {
  margin-top: 0.1rem;
}

.alert-info {
  background: rgba(37, 99, 235, 0.06);
  border-left-color: var(--color-primary-light);
  color: var(--color-primary);
}

.alert-success {
  background: rgba(21, 128, 61, 0.07);
  border-left-color: var(--color-success);
  color: var(--color-success);
}

.alert-danger {
  background: rgba(185, 28, 28, 0.07);
  border-left-color: var(--color-error);
  color: var(--color-error);
}

.alert-warning {
  background: rgba(180, 83, 9, 0.07);
  border-left-color: var(--color-warning);
  color: var(--color-warning);
}

:root[data-theme="dark"] .alert-info {
  background: rgba(96, 165, 250, 0.15);
  color: var(--color-text);
}

:root[data-theme="dark"] .alert-success {
  background: rgba(52, 211, 153, 0.15);
  color: var(--color-text);
}

:root[data-theme="dark"] .alert-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--color-text);
}

:root[data-theme="dark"] .alert-warning {
  background: rgba(250, 204, 21, 0.15);
  color: var(--color-text);
}

/* =========================================================
   RESULTADOS / DESCARGA
   ========================================================= */
.tool-output {
  margin-top: 2rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.tool-output-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.btn-download {
  background: var(--color-primary-light);
  color: #fff;
  padding: 0.8rem 1.4rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-download:hover {
  background: var(--color-primary);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.8rem 1.4rem;
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-secondary:hover {
  border-color: var(--color-primary-light);
  color: var(--color-primary);
  background: var(--color-soft);
  transform: translateY(-1px);
}

/* =========================================================
   FOOTER
   ========================================================= */
.dashboard-footer {
  text-align: center;
  padding: 1rem;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.85rem;
  margin-top: auto;
  box-shadow: var(--shadow-sm);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 768px) {
  .dashboard-header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .header-actions {
    width: 100%;
    justify-content: center;
  }

  .ofs-logo {
    margin-bottom: 0.5rem;
    justify-content: center;
  }

  .logo-text {
    font-size: 1.6rem;
  }

  .logo-subtext {
    font-size: 1.1rem;
  }

  .user-info {
    flex-direction: column;
    text-align: center;
  }

  .primary-nav {
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 1.2rem;
    margin: 0.6rem 1.2rem 0;
    border-radius: 1.2rem;
  }

  .primary-nav .nav-links {
    width: 100%;
    justify-content: center;
  }

  .tools-grid {
    grid-template-columns: 1fr;
  }

  form {
    align-items: stretch;
  }

  input[type="file"]::file-selector-button {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

@media (max-width: 640px) {
  .dashboard-main {
    padding: 2rem 1rem 2.5rem;
  }

  .tool-section {
    padding: 1.5rem;
  }

  .header-actions {
    width: 100%;
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn-toggle,
  .btn-back,
  .btn-process,
  .btn-download,
  .file-upload-clear {
    width: 100%;
    justify-content: center;
  }

  .theme-toggle {
    min-width: auto;
  }

  .primary-nav .nav-links {
    justify-content: center;
  }

  .file-upload-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .file-upload-stats {
    justify-content: space-between;
  }

  .tool-output-actions {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .dashboard-header {
    padding: 1rem;
  }

  .logo-text {
    font-size: 1.4rem;
  }

  .logo-subtext {
    font-size: 1rem;
  }

  .file-upload-label {
    padding: 1.5rem 1rem;
  }

  .file-upload-icon {
    font-size: 1.6rem;
  }

  .tool-card {
    padding: 1.5rem 1rem;
  }
}

/* =========================================================
   TOAST NOTIFICATIONS
   ========================================================= */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 400px;
}

.toast {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  min-width: 300px;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInRight 0.3s ease;
  border-left: 4px solid transparent;
}

.toast-success {
  border-left-color: var(--color-success);
}

.toast-error {
  border-left-color: var(--color-error);
}

.toast-warning {
  border-left-color: var(--color-warning);
}

.toast-info {
  border-left-color: var(--color-primary-light);
}

.toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.toast-success .toast-icon {
  color: var(--color-success);
}

.toast-error .toast-icon {
  color: var(--color-error);
}

.toast-warning .toast-icon {
  color: var(--color-warning);
}

.toast-info .toast-icon {
  color: var(--color-primary-light);
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-message {
  font-size: 0.9rem;
  color: var(--color-text);
  line-height: 1.4;
  word-wrap: break-word;
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1.25rem;
  flex-shrink: 0;
  transition: var(--transition);
}

.toast-close:hover {
  color: var(--color-text);
}

@keyframes slideInRight {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(400px);
  }
}

/* =========================================================
   LOADING OVERLAY
   ========================================================= */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.3s ease;
}

.loading-content {
  background: var(--color-surface);
  padding: 2.5rem;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  min-width: 300px;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary-light);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

#loadingMessage {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

#loadingSubtext {
  font-size: 0.9rem;
  color: var(--color-muted);
  margin: 0;
}

.loading-progress {
  margin-top: 1.25rem;
  height: 10px;
  background: var(--color-bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.loading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary-light), var(--color-accent));
  transition: width 0.4s ease;
}

.loading-progress-text {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* =========================================================
   FILE PREVIEW
   ========================================================= */
.file-preview-list {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  display: none;
  max-height: 260px;
  overflow: auto;
}

.file-preview-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.2s ease;
}

.file-preview-item:last-child {
  border-bottom: none;
}

.file-preview-item:hover {
  background: rgba(37, 99, 235, 0.05);
  border-radius: 6px;
}

.file-preview-icon {
  color: var(--color-primary-light);
  font-size: 1.5rem;
  flex-shrink: 0;
}

.file-preview-info {
  flex: 1;
  min-width: 0;
}

.file-preview-name {
  font-weight: 600;
  color: var(--color-text);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-size {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 0.2rem;
}

.file-preview-remove {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-error);
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  transition: var(--transition);
  flex-shrink: 0;
}

.file-preview-remove:hover {
  background: var(--color-error);
  color: white;
  border-color: var(--color-error);
}

.file-preview-more {
  background: rgba(37, 99, 235, 0.03);
}

.file-preview-more .file-preview-icon {
  color: var(--color-muted);
}

/* =========================================================
   DRAG AND DROP STATES
   ========================================================= */
.file-upload.drag-active .file-upload-label {
  border-color: var(--color-primary-light);
  background: rgba(37, 99, 235, 0.1);
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* =========================================================
   ACCESSIBILITY FEATURES
   ========================================================= */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: white;
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  z-index: 100;
  border-radius: 0 0 var(--radius) 0;
  font-weight: 600;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--color-primary-light);
  outline-offset: 2px;
}

/* Focus styles for accessibility */
:focus-visible {
  outline: 3px solid var(--color-primary-light);
  outline-offset: 2px;
  border-radius: 4px;
}

.tool-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 0 0 3px var(--color-primary-light), var(--shadow-md);
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--color-primary-light);
  outline-offset: 2px;
}

/* Screen reader only class */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* =========================================================
   MICRO-INTERACTIONS & ANIMATIONS
   ========================================================= */

/* Smooth scroll for entire page */
html {
  scroll-behavior: smooth;
}

/* Enhanced card hover effects */
.tool-card {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, transparent 0%, rgba(37, 99, 235, 0.08) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tool-card:hover::before {
  opacity: 1;
}

.tool-card:hover i {
  transform: scale(1.1) rotate(3deg);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Button ripple effect */
.btn-process,
.btn-download {
  position: relative;
  overflow: hidden;
}

.btn-process::after,
.btn-download::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-process:active::after,
.btn-download:active::after {
  width: 300px;
  height: 300px;
}

/* Page load animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tool-card {
  animation: fadeInUp 0.6s ease backwards;
}

.tool-card:nth-child(1) { animation-delay: 0.1s; }
.tool-card:nth-child(2) { animation-delay: 0.2s; }
.tool-card:nth-child(3) { animation-delay: 0.3s; }
.tool-card:nth-child(4) { animation-delay: 0.4s; }

/* Alert slide-in animation */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.alert {
  animation: slideInLeft 0.4s ease;
}

/* Improved form note appearance */
.form-note {
  animation: fadeIn 0.5s ease;
}

/* Enhanced button hover states */
.btn-process,
.btn-download,
.btn-back {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-process:hover,
.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.3);
}

.btn-back:hover {
  transform: translateX(-3px);
}

/* Mobile toast positioning */
@media (max-width: 768px) {
  .toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }

  .toast {
    min-width: auto;
    max-width: none;
  }

  .loading-content {
    margin: 0 1rem;
    min-width: auto;
  }

  @keyframes slideInRight {
    from {
      transform: translateY(-100px);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  @keyframes fadeOut {
    to {
      opacity: 0;
      transform: translateY(-100px);
    }
  }
}
