/* ==========================================================================
   Estilos Canónicos: Generador y validador de enlaces UTM
   Fijate Tools - 2026
   ========================================================================== */

:root {
  --bg-body: #0b0f17;
  --bg-card: #131b2e;
  --bg-card-sub: #1a243b;
  --bg-input: #0f1626;
  --border-color: #24304f;
  --border-focus: #3b82f6;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.25);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-sub: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #2563eb;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent-primary: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-glow: rgba(37, 99, 235, 0.18);
  --success: #059669;
  --success-bg: rgba(5, 150, 105, 0.12);
  --warning: #d97706;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-body);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  color: var(--text-main);
  margin-top: 0;
}

/* Layout y contención canónica */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
  box-sizing: border-box;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* Tarjeta principal */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
  margin-bottom: 2rem;
}

/* Presets de campaña */
.presets-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.presets-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: none;
}

.presets-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-preset {
  background: var(--bg-card-sub);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  font-size: 0.825rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  min-height: 38px;
}

.btn-preset:hover, .btn-preset.active {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* Formulario */
.form-group-main {
  margin-bottom: 1.5rem;
}

.utm-grid-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.field-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.required-badge {
  font-size: 0.725rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  font-weight: 600;
}

.optional-badge {
  font-size: 0.725rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card-sub);
  color: var(--text-muted);
  font-weight: 500;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon svg {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  pointer-events: none;
}

.input-with-icon .form-input {
  padding-left: 2.75rem;
}

.form-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  min-height: 44px;
  transition: var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field-hint {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  margin-bottom: 0;
  line-height: 1.4;
}

/* Opciones de limpieza */
.cleaning-options-box {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}

.cleaning-title {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.options-flex {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-main);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.separator-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-main);
}

.form-select-inline {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.4rem 2rem 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  min-height: 38px;
}

.form-select-inline option {
  background: var(--bg-card);
  color: var(--text-main);
}

/* Caja de resultado */
.result-section {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

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

.result-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.result-title {
  font-size: 1.15rem;
  margin: 0;
}

.char-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.result-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-action-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.6rem 1.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  min-height: 42px;
}

.btn-action-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-action-primary.copied {
  background: var(--success);
}

.btn-action-secondary, .btn-action-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  min-height: 42px;
}

.btn-action-secondary:hover, .btn-action-ghost:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.url-output-container {
  margin-bottom: 1.5rem;
}

.url-text-box {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  color: var(--text-main);
  word-break: break-all;
  line-height: 1.6;
  user-select: all;
  min-height: 48px;
}

/* Desglose y QR */
.details-and-qr-grid {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 1.5rem;
  align-items: stretch;
}

.params-table-card, .qr-code-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.card-subtitle {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.params-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.param-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  background: var(--bg-card-sub);
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
}

.param-name {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent-primary);
  font-weight: 600;
}

.param-val {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-main);
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qr-code-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.qr-canvas-wrapper {
  background: #ffffff;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.btn-download-qr {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--bg-card-sub);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.775rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: var(--transition);
  min-height: 38px;
}

.btn-download-qr:hover {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

/* Historial */
.history-section {
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

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

.history-title {
  font-size: 1.15rem;
  margin: 0;
}

.history-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-text-action {
  background: none;
  border: none;
  color: var(--accent-primary);
  font-size: 0.825rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
}

.btn-text-action:hover {
  text-decoration: underline;
}

.btn-text-action.danger {
  color: var(--danger);
}

.history-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.history-table th {
  background: var(--bg-card-sub);
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.history-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.history-table tr:last-child td {
  border-bottom: none;
}

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

.td-url {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.775rem;
}

.btn-history-copy, .btn-history-delete {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.75rem;
  margin-right: 0.25rem;
}

.btn-history-copy:hover {
  background: var(--accent-primary);
  color: #ffffff;
}

.btn-history-delete:hover {
  background: var(--danger);
  color: #ffffff;
}

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

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  animation: modalScale 0.2s ease-out;
}

@keyframes modalScale {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-title {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
}

.modal-message {
  color: var(--text-muted);
  font-size: 0.925rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

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

.btn-modal-cancel {
  background: var(--bg-card-sub);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.6rem 1.15rem;
  font-size: 0.875rem;
  cursor: pointer;
  min-height: 40px;
}

.btn-modal-confirm {
  background: var(--danger);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.6rem 1.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
}

.btn-modal-confirm:hover {
  background: var(--danger-hover);
}

/* Responsive móvil */
@media (max-width: 768px) {
  .card-main {
    padding: 1.25rem;
  }

  .utm-grid-fields {
    grid-template-columns: 1fr;
  }

  .details-and-qr-grid {
    grid-template-columns: 1fr;
  }

  .options-flex {
    flex-direction: column;
    align-items: flex-start;
  }

  .result-actions {
    width: 100%;
  }

  .btn-action-primary, .btn-action-secondary, .btn-action-ghost {
    width: 100%;
    justify-content: center;
  }
}
