/* Estilos globales y reset moderno */
:root {
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --bg-primary: #0b0f19;
  --bg-secondary: #131b2e;
  --bg-card: #182238;
  --bg-card-hover: #1f2d4a;
  --border-color: #273552;
  --border-focus: #3b82f6;
  
  --cf-orange: #f38020;
  --cf-orange-hover: #e06c0c;
  --cf-orange-light: rgba(243, 128, 32, 0.15);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.15);
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.15);
  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.15);
  --color-info: #0ea5e9;
  --color-info-bg: rgba(14, 165, 233, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Enfoque accesible */
:focus-visible {
  outline: 3px solid var(--border-focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* Layout general */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-container {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem 1rem;
  flex: 1;
}

/* Encabezado */
.app-header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-content {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 2rem;
  line-height: 1;
}

.logo-area h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge-cf {
  background-color: var(--cf-orange-light);
  color: var(--cf-orange);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
  border: 1px solid rgba(243, 128, 32, 0.3);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.header-badges {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.security-badge {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.version-badge {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

/* Tarjeta informativa preliminar */
.info-card {
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.info-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.info-icon {
  font-size: 1.25rem;
}

.info-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

.info-intro {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.process-steps-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

@media (min-width: 640px) {
  .process-steps-list {
    grid-template-columns: 1fr 1fr;
  }
}

.process-steps-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.process-steps-list li strong {
  color: var(--text-primary);
}

.step-num {
  background: var(--cf-orange);
  color: #fff;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

/* Opciones de publicación */
.options-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

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

.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .options-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.toggle-control {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  background: var(--bg-card);
  padding: 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: border-color 0.2s, background-color 0.2s;
}

.toggle-control:hover {
  border-color: var(--cf-orange);
  background-color: var(--bg-card-hover);
}

.toggle-control input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  background-color: var(--border-color);
  border-radius: 20px;
  position: relative;
  flex-shrink: 0;
  transition: background-color 0.2s;
  margin-top: 0.15rem;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-control input:checked + .toggle-slider {
  background-color: var(--cf-orange);
}

.toggle-control input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

.toggle-label {
  display: flex;
  flex-direction: column;
}

.toggle-label strong {
  font-size: 0.85rem;
  color: var(--text-primary);
}

.toggle-label small {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 0.2rem;
}

/* Zona de carga Drag and Drop */
.upload-section {
  margin-bottom: 1.5rem;
}

.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  background-color: var(--bg-secondary);
  padding: 3rem 1.5rem;
  text-align: center;
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  position: relative;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--cf-orange);
  background-color: rgba(243, 128, 32, 0.05);
}

.drop-zone.dragover {
  border-color: var(--cf-orange);
  background-color: rgba(243, 128, 32, 0.1);
  transform: scale(1.01);
}

.drop-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.drop-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.drop-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
}

.file-limits-info {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--cf-orange);
  color: #fff;
  box-shadow: 0 2px 8px rgba(243, 128, 32, 0.4);
}

.btn-primary:hover {
  background-color: var(--cf-orange-hover);
  box-shadow: 0 4px 12px rgba(243, 128, 32, 0.5);
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--text-secondary);
}

.btn-warning {
  background-color: var(--color-warning);
  color: #1a1a1a;
}

.btn-warning:hover {
  background-color: #d97706;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  text-align: left;
}

.btn-outline:hover {
  border-color: var(--cf-orange);
  background-color: var(--bg-card);
}

.btn-link {
  background: none;
  border: none;
  color: var(--cf-orange);
  text-decoration: underline;
  cursor: pointer;
}

.btn-link:hover {
  color: var(--cf-orange-hover);
}

.btn-lg {
  padding: 0.85rem 1.5rem;
  font-size: 1.05rem;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
}

/* Progreso */
.progress-section {
  margin-bottom: 1.5rem;
}

.progress-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.progress-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid rgba(243, 128, 32, 0.2);
  border-top-color: var(--cf-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.progress-bar-track {
  width: 100%;
  height: 10px;
  background-color: var(--bg-primary);
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cf-orange) 0%, #faad3f 100%);
  border-radius: 9999px;
  transition: width 0.3s ease;
}

.progress-percentage {
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.activity-log-container {
  margin-top: 1rem;
}

.activity-log-container summary {
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.activity-log {
  background-color: #06090f;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.75rem;
  color: #a5f3fc;
  max-height: 180px;
  overflow-y: auto;
  margin-top: 0.5rem;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Banner de error */
.error-banner {
  background-color: var(--color-danger-bg);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.error-icon {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.error-content h3 {
  font-size: 1.1rem;
  color: #fca5a5;
  margin-bottom: 0.25rem;
}

.error-content p {
  font-size: 0.9rem;
  color: #fee2e2;
  margin-bottom: 0.75rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.alert-box-warning {
  background-color: var(--color-warning-bg);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  color: #fef3c7;
  font-size: 0.85rem;
}

.alert-box-warning strong {
  color: #f59e0b;
  display: block;
  margin-bottom: 0.25rem;
}

.build-choice-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.build-choice-grid .btn {
  justify-content: flex-start;
  padding: 1rem;
}

.btn-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.btn-text {
  display: flex;
  flex-direction: column;
}

.btn-text small {
  color: var(--text-muted);
  font-weight: normal;
  margin-top: 0.2rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.badge-code {
  font-family: monospace;
  background-color: #0f172a;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  color: #38bdf8;
  font-size: 0.85rem;
}

/* Resultados */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.results-header {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.results-title-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.success-icon {
  font-size: 2.25rem;
  line-height: 1;
}

.badge-cf-success {
  background-color: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
}

/* Métricas */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 640px) {
  .metrics-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.metric-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
}

.metric-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.text-accent {
  color: #38bdf8;
}

.text-safe {
  color: var(--color-success);
}

/* Avisos */
.warnings-box {
  background-color: var(--color-warning-bg);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

.warnings-box h4 {
  font-size: 0.95rem;
  color: #fbbf24;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.warnings-box ul {
  padding-left: 1.25rem;
  font-size: 0.85rem;
  color: #fef3c7;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Panel de acciones */
.actions-panel {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.action-buttons-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.action-buttons-group .btn {
  flex: 1 1 240px;
}

/* Guía de Cloudflare */
.cf-guide-card {
  background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(243, 128, 32, 0.08) 100%);
  border: 1px solid rgba(243, 128, 32, 0.3);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}

.cf-guide-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.cf-guide-steps {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .cf-guide-steps {
    grid-template-columns: 1fr 1fr;
  }
}

.cf-guide-step {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.cf-step-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cf-orange);
  margin-bottom: 0.4rem;
}

.cf-guide-step a {
  color: var(--cf-orange);
  text-decoration: underline;
}

.code-snippet-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #070b13;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-top: 0.5rem;
  gap: 0.5rem;
}

.code-snippet-box code {
  font-family: monospace;
  font-size: 0.75rem;
  color: #38bdf8;
  overflow-x: auto;
  white-space: nowrap;
}

.btn-copy {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  flex-shrink: 0;
}

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

/* Árbol de archivos */
.tree-section {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}

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

.tree-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.filter-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.filter-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-pill.active,
.filter-pill:hover {
  background: var(--cf-orange);
  color: #fff;
  border-color: var(--cf-orange);
}

.file-tree-container {
  background-color: #070b13;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  max-height: 320px;
  overflow-y: auto;
  padding: 0.5rem;
}

.file-tree-list {
  list-style: none;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.82rem;
}

.file-tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.file-tree-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.tree-item-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-item-icon {
  flex-shrink: 0;
}

.tree-item-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.tree-badge-gen {
  background-color: rgba(14, 165, 233, 0.2);
  color: #38bdf8;
  font-size: 0.68rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.tree-item-size {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Aviso específico de Cloudflare para TypeScript */
.cf-ts-notice-box {
  margin-top: 1rem;
  background-color: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  color: #fef3c7;
}

.cf-ts-badge {
  display: inline-block;
  font-weight: 700;
  color: #fbbf24;
  margin-bottom: 0.4rem;
}

.cf-ts-notice-box p {
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.cf-ts-notice-box ul {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.cf-ts-notice-box code {
  font-family: monospace;
  background: #0b0f19;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  color: #38bdf8;
}

/* Pie de página */
.app-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
}
