/* ============================================================
   03 — COMPONENTS — Reveal, WhatsApp flotante, IA, Forms
   ============================================================ */

/* ============== REVEAL ============== */
.reveal {
    opacity: 0; transform: translateY(40px);
    transition: opacity 0.9s ease, transform 1s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .reveal.in { opacity: 1; transform: translateY(0); }

/* ============== WHATSAPP FLOATING — NUEVO ============== */
.wa-float {
    position: fixed; bottom: 24px; right: 24px;
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--wa-green); color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.4);
    z-index: 9990; text-decoration: none;
    transition: transform 0.2s ease;
    cursor: pointer; border: none;
  }
  .wa-float:hover { transform: scale(1.08); }
  .wa-tooltip {
    position: fixed; bottom: 38px; right: 96px;
    background: var(--ink); color: #fff;
    font-family: 'Inter', sans-serif; font-size: 13px;
    padding: 12px 16px; border-radius: 6px;
    z-index: 9989;
    opacity: 0; pointer-events: none;
    transform: translateX(10px);
    transition: opacity 0.4s, transform 0.4s;
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  }
  .wa-tooltip::after {
    content: ''; position: absolute; right: -6px; top: 50%;
    transform: translateY(-50%);
    border-left: 6px solid var(--ink);
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
  }
  .wa-tooltip.visible { opacity: 1; transform: translateX(0); pointer-events: auto; }
  .wa-tooltip-close {
    background: none; border: none; color: rgba(255,255,255,0.6);
    margin-left: 12px; cursor: pointer; font-size: 16px;
    padding: 0; line-height: 1;
  }
  @media (max-width: 640px) {
    .wa-float { bottom: 20px; right: 20px; width: 56px; height: 56px; }
    .wa-tooltip { bottom: 92px; right: 20px; }
    .wa-tooltip::after {
      right: 20px; top: auto; bottom: -6px; transform: none;
      border-top: 6px solid var(--ink); border-bottom: none;
      border-left: 6px solid transparent; border-right: 6px solid transparent;
    }
  }

/* ============== AI AGENT WIDGET — NUEVO ============== */
.ai-launcher {
    position: fixed; bottom: 24px; left: 24px;
    width: auto; padding: 14px 20px 14px 16px; gap: 10px;
    background: var(--ink); color: var(--paper);
    border-radius: 999px; border: none;
    display: flex; align-items: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    cursor: pointer; z-index: 9988;
    font-family: 'Inter', sans-serif;
    font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
    transition: transform 0.2s, background 0.3s;
  }
  .ai-launcher:hover { background: var(--red); transform: translateY(-2px); }
  .ai-launcher .pulse-dot {
    width: 8px; height: 8px; background: var(--red);
    border-radius: 50%;
    animation: pulse 1.5s ease infinite;
  }
  .ai-launcher:hover .pulse-dot { background: #fff; }
  @keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.4); }
  }

  .ai-panel {
    position: fixed; bottom: 0; right: 0;
    width: 100%; max-width: 420px; height: 100vh; max-height: 720px;
    background: var(--paper); z-index: 9999;
    display: flex; flex-direction: column;
    box-shadow: -10px 0 40px rgba(0,0,0,0.15);
    transform: translateX(110%);
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    border-left: 1px solid var(--line);
  }
  .ai-panel.open { transform: translateX(0); }
  @media (min-width: 768px) {
    .ai-panel {
      bottom: 24px; right: 24px;
      max-height: 640px;
      border: 1px solid var(--line);
      border-radius: 0;
    }
    .ai-panel.open { transform: translate(0, 0); }
  }

  .ai-header {
    padding: 24px 24px 20px;
    background: var(--ink); color: var(--paper);
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 12px;
  }
  .ai-header .who {
    display: flex; flex-direction: column; gap: 4px;
  }
  .ai-header .title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 22px; font-weight: 400; font-style: italic;
    letter-spacing: -0.01em;
  }
  .ai-header .subtitle {
    font-size: 10px; letter-spacing: 0.28em;
    text-transform: uppercase; color: rgba(255,255,255,0.6);
  }
  .ai-header .status {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 10px; letter-spacing: 0.2em;
    text-transform: uppercase; color: var(--bone);
    margin-top: 6px;
  }
  .ai-header .status .dot {
    width: 6px; height: 6px; background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s ease infinite;
  }
  .ai-close {
    background: none; border: none; color: var(--paper);
    cursor: pointer; padding: 4px;
    font-size: 22px; line-height: 1; opacity: 0.8;
    transition: opacity 0.3s;
  }
  .ai-close:hover { opacity: 1; }

  .ai-messages {
    flex-grow: 1; overflow-y: auto;
    padding: 20px 24px;
    display: flex; flex-direction: column; gap: 14px;
    background: var(--paper);
  }
  .ai-msg {
    max-width: 85%;
    padding: 14px 18px;
    font-size: 14px; line-height: 1.55;
    border-radius: 4px;
    animation: msgIn 0.4s ease both;
  }
  @keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .ai-msg.bot {
    background: var(--paper-warm);
    color: var(--ink-soft);
    align-self: flex-start;
    font-family: 'Cormorant Garamond', serif;
    font-size: 16px; line-height: 1.5;
  }
  .ai-msg.user {
    background: var(--ink); color: var(--paper);
    align-self: flex-end;
    font-family: 'Inter', sans-serif;
  }

  .ai-typing {
    display: inline-flex; gap: 4px; padding: 14px 18px;
    background: var(--paper-warm); align-self: flex-start;
    border-radius: 4px;
  }
  .ai-typing span {
    width: 6px; height: 6px; background: var(--muted);
    border-radius: 50%; animation: typing 1.4s ease infinite;
  }
  .ai-typing span:nth-child(2) { animation-delay: 0.2s; }
  .ai-typing span:nth-child(3) { animation-delay: 0.4s; }
  @keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
  }

  .ai-suggestions {
    padding: 8px 24px 4px;
    display: flex; flex-wrap: wrap; gap: 8px;
    border-top: 1px solid var(--line);
    background: var(--paper);
  }
  .ai-chip {
    font-size: 11px; letter-spacing: 0.08em;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink-soft);
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
  }
  .ai-chip:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

  .ai-input-bar {
    padding: 16px 20px 20px;
    background: var(--paper);
    display: flex; gap: 10px; align-items: center;
    border-top: 1px solid var(--line);
  }
  .ai-input {
    flex-grow: 1;
    border: 1px solid var(--line);
    background: var(--paper);
    padding: 12px 14px;
    font-family: 'Inter', sans-serif;
    font-size: 14px; color: var(--ink);
    border-radius: 0; outline: none;
    transition: border-color 0.3s;
  }
  .ai-input:focus { border-color: var(--ink); }
  .ai-send {
    background: var(--ink); color: var(--paper);
    border: none; cursor: pointer;
    padding: 12px 16px;
    font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
    font-family: inherit;
    transition: background 0.3s;
  }
  .ai-send:hover { background: var(--red); }
  .ai-send:disabled { opacity: 0.4; cursor: not-allowed; }

  /* === Footer del chat — branding SABERHOY ESPODER === */
  .ai-powered {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding-top: 16px;
    margin-top: 12px;
    border-top: 1px solid #f0eeea;
  }
  .ai-powered-label {
    color: #6b6660;
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
  }
  .ai-powered-logo {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
  }
  .ai-powered-brand {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 600;
    color: #3c7f99;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 12px;
  }
  .ai-powered-brand sup {
    font-size: 8px;
    vertical-align: super;
    margin-left: 1px;
    letter-spacing: 0;
  }

/* ============== FORM MODAL — NUEVO ============== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(17,17,17,0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .modal-overlay.open { opacity: 1; pointer-events: auto; }

  .modal {
    background: var(--paper);
    width: 100%; max-width: 540px;
    max-height: 90vh; overflow-y: auto;
    padding: 48px 44px 40px;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.4s ease;
  }
  .modal-overlay.open .modal { transform: translateY(0); }

  .modal-close {
    position: absolute; top: 16px; right: 16px;
    background: none; border: none;
    font-size: 26px; line-height: 1; cursor: pointer;
    color: var(--muted); padding: 8px;
    transition: color 0.3s;
  }
  .modal-close:hover { color: var(--red); }

  .modal .eyebrow { display: block; margin-bottom: 16px; }
  .modal h3 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 32px; font-weight: 400; font-style: italic;
    line-height: 1.1; letter-spacing: -0.01em;
    margin-bottom: 12px;
  }
  .modal h3 em { color: var(--red); }
  .modal .modal-sub {
    font-size: 14px; color: var(--muted);
    line-height: 1.6; margin-bottom: 32px;
  }

  .form-field {
    margin-bottom: 20px;
    display: flex; flex-direction: column;
  }
  .form-field label {
    font-size: 10px; letter-spacing: 0.24em;
    text-transform: uppercase; color: var(--ink);
    margin-bottom: 8px; font-weight: 500;
  }
  .form-field label .req { color: var(--red); }
  .form-field input,
  .form-field select,
  .form-field textarea {
    border: 1px solid var(--line);
    background: var(--paper);
    padding: 12px 14px;
    font-family: 'Inter', sans-serif;
    font-size: 14px; color: var(--ink);
    border-radius: 0; outline: none;
    transition: border-color 0.3s;
  }
  .form-field input:focus,
  .form-field select:focus,
  .form-field textarea:focus { border-color: var(--ink); }
  .form-field textarea { resize: vertical; min-height: 90px; font-family: inherit; }
  .form-field .hint {
    font-size: 11px; color: var(--muted);
    margin-top: 4px;
  }

  /* honeypot — invisible para humanos, llenable por bots automáticos */
  .hp-field {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
  }

  /* Bloque de error inline (se inyecta desde forms.js si el POST falla) */
  .form-error {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    margin-top: 8px;
    margin-bottom: 16px;
    background: rgba(196, 18, 26, 0.06);
    border-left: 3px solid var(--red);
  }
  .form-error .form-error-msg {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    line-height: 1.55;
    color: var(--ink);
    margin: 0;
  }
  .form-error .form-error-link {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--red);
    text-decoration: none;
    font-weight: 500;
    align-self: flex-start;
    border-bottom: 1px solid var(--red);
    padding-bottom: 2px;
    transition: color 0.3s, border-color 0.3s;
  }
  .form-error .form-error-link:hover {
    color: var(--ink);
    border-color: var(--ink);
  }

  .form-submit {
    width: 100%; margin-top: 8px;
    background: var(--ink); color: var(--paper);
    padding: 16px; border: none; cursor: pointer;
    font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase;
    font-family: inherit;
    transition: background 0.3s;
  }
  .form-submit:hover { background: var(--red); }
  .form-submit:disabled { opacity: 0.5; cursor: not-allowed; }

  .form-success {
    text-align: center; padding: 32px 0;
    display: none;
  }
  .form-success.show { display: block; }
  .form-success svg {
    width: 56px; height: 56px;
    margin: 0 auto 20px; color: var(--red);
  }
  .form-success h4 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 26px; font-style: italic; font-weight: 400;
    margin-bottom: 12px;
  }
  .form-success p { font-size: 14px; color: var(--ink-soft); line-height: 1.6; }

  @media (max-width: 540px) {
    .modal { padding: 36px 24px 28px; }
    .modal h3 { font-size: 26px; }
  }
