/* ===== LM Express Pickup Email Builder – Main styles ===== */
:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --border: #e1e4e8;
  --primary: #1a1a2e;
  --primary-light: #2d2d44;
  --accent: #e63946;
  --accent-hover: #c42d3a;
  --success: #0d6832;
  --success-bg: #d4edda;
  --error: #721c24;
  --error-bg: #f8d7da;
  --warn: #856404;
  --warn-bg: #fff3cd;
  --text: #333333;
  --text-muted: #555555;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ----- Layout ----- */
.app-header {
  background: var(--primary);
  color: #fff;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.app-header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}

.app-header p {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  opacity: 0.9;
}

.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ----- Wizard steps ----- */
.wizard-steps {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.5rem;
  box-shadow: var(--shadow);
}

.wizard-step {
  flex: 1;
  text-align: center;
  padding: 0.6rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  position: relative;
  transition: color var(--transition), background var(--transition);
}

.wizard-step::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: -1;
}

.wizard-step:last-child::after { display: none; }

.wizard-step.is-active {
  color: var(--primary);
  background: rgba(26, 26, 46, 0.08);
}

.wizard-step.is-done {
  color: var(--success);
}

.wizard-step .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  margin-right: 0.35rem;
  font-size: 0.8rem;
}

.wizard-step.is-active .step-num {
  background: var(--primary);
  color: #fff;
}

.wizard-step.is-done .step-num {
  background: var(--success);
  color: #fff;
}

/* ----- Panels (step content) ----- */
.wizard-panel {
  display: none;
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.wizard-panel.is-visible {
  display: flex;
  flex-direction: column;
  min-height: 60vh;
}

.wizard-panel h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  color: var(--primary);
}

/* Sticky action bar at bottom of panel – always visible when list is long */
.panel-actions-sticky {
  position: sticky;
  bottom: 0;
  margin: 1.5rem -1.5rem -1.5rem;
  padding: 1rem 1.5rem 1.25rem;
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
  z-index: 5;
}

.panel-actions-sticky .btn-group {
  margin-top: 0;
  flex-wrap: wrap;
}

/* ----- Form elements ----- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
  color: var(--text);
}

.form-label .optional {
  font-weight: 400;
  color: var(--text-muted);
}

.form-input,
.form-input-url {
  width: 100%;
  max-width: 420px;
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-input-url:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.12);
}

.form-input.is-invalid,
.form-input-url.is-invalid {
  border-color: var(--accent);
}

.form-input.is-valid,
.form-input-url.is-valid {
  border-color: #28a745;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.form-error {
  font-size: 0.8rem;
  color: var(--error);
  margin-top: 0.35rem;
}

/* ----- Step 1: Cargar datos ----- */
.step1-intro {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.step1-section {
  margin-bottom: 2rem;
}

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

.step1-channel .channel-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.step1-channel .channel-option {
  margin: 0;
  cursor: pointer;
}

.step1-channel .channel-option input {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  pointer-events: none;
}

.channel-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  padding: 1.25rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.channel-option:hover .channel-card {
  border-color: var(--primary-light);
  background: rgba(26, 26, 46, 0.03);
}

.channel-option input:focus-visible + .channel-card {
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.2);
}

.channel-option input:checked + .channel-card {
  border-color: var(--accent);
  background: rgba(230, 57, 70, 0.06);
  box-shadow: 0 0 0 1px var(--accent);
}

.channel-icon {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.channel-name {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--primary);
}

.channel-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  text-align: center;
  line-height: 1.3;
}

.step1-files-hint {
  margin-bottom: 1rem;
}

.step1-file-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.step1-file-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.step1-file-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
}

.step1-file-item .file-zone {
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

@media (max-width: 640px) {
  .step1-channel .channel-picker {
    grid-template-columns: 1fr;
  }
  .step1-file-grid {
    grid-template-columns: 1fr;
  }
}

.channel-picker {
  display: flex;
  gap: 1rem;
}

.channel-option {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

/* File inputs ----- */
.file-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  background: #fafbfc;
  transition: border-color var(--transition), background var(--transition);
}

.file-zone.is-dragover {
  border-color: var(--primary);
  background: rgba(26, 26, 46, 0.04);
}

.file-zone.is-filled {
  border-style: solid;
  border-color: var(--success);
  background: var(--success-bg);
}

.file-zone input[type="file"] {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.file-zone label,
.file-zone .file-zone-label {
  cursor: pointer;
  font-weight: 500;
  color: var(--primary);
  text-decoration: underline;
}

.file-zone .file-name {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.file-zone .file-name strong {
  color: var(--text);
}

.file-validation {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  min-height: 1.2em;
}

.file-validation.is-ok {
  color: var(--success);
}

.file-validation.is-err {
  color: var(--error);
}

/* Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.2);
}

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

.btn:not(:disabled):active {
  transform: scale(0.98);
}

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

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

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

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

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(26, 26, 46, 0.06);
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* Table ----- */
.data-table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.data-table tbody tr:hover {
  background: #f8f9fa;
}

.data-table tbody tr.row-click-preview {
  cursor: pointer;
}

.data-table tbody tr.row-click-preview:hover {
  background: #eef0f4;
}

.data-table tbody tr.unmatched {
  background: var(--warn-bg);
}

.data-table tbody tr.unmatched:hover {
  background: #ffeaa7;
}

.data-table .table-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.data-table .table-link:hover {
  text-decoration: underline;
}

/* Alerts / Status ----- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-top: 1rem;
  font-size: 0.9rem;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
}

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

.alert-warning {
  background: var(--warn-bg);
  color: var(--warn);
}

.alert-info {
  background: #cce5ff;
  color: #004085;
}

.bulk-progress-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.bulk-progress-wrap .bulk-progress-text {
  flex: 1;
  min-width: 0;
}

.bulk-progress-wrap .bulk-stop-btn {
  flex-shrink: 0;
  font-size: 0.9rem;
}

/* Summary card ----- */
.summary-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: #f8f9fa;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.summary-card .count {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.summary-card .label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.send-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 2rem;
  padding: 1rem 1.25rem;
  background: #f8f9fa;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.send-metrics span {
  font-weight: 500;
  color: var(--text);
}

.send-metrics span strong {
  color: var(--primary);
}

/* Lightbox ----- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.lightbox.is-open {
  display: flex;
}

.lightbox-modal {
  background: var(--card);
  border-radius: 12px;
  width: 100%;
  max-width: 700px;
  height: 95vh;
  max-height: 95vh;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--primary);
  color: #fff;
}

.lightbox-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.lightbox-close {
  background: transparent;
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0;
  transition: background var(--transition);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.lightbox-body .preview-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  border-radius: 0;
  background: #f4f4f4;
}

.lightbox-body .status {
  margin: 0.75rem 1.25rem 1rem;
}

/* Confirm modal ----- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1001;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal-box h3 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.modal-box p {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.modal-box .form-group {
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* Responsive ----- */
@media (max-width: 600px) {
  .app-main {
    padding: 1rem;
  }

  .wizard-steps {
    flex-direction: column;
  }

  .wizard-step::after {
    display: none;
  }

  .btn-group {
    flex-direction: column;
  }

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

  .form-input,
  .form-input-url {
    max-width: none;
  }
}

/* Focus visible for accessibility ----- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
