/* ═══════════════════════════════════════════════════════════════════
   LS DOMÓTICA — ai-designer.css
   ------------------------------------------------------------------
   Sección del Diseñador IA + Demo Home Assistant.
   Dos columnas en desktop (prompt/result | demo), stack en mobile.
═══════════════════════════════════════════════════════════════════ */

.ai-section {
  position: relative;
  padding: clamp(64px, 10vw, 120px) 20px;
  overflow: hidden;
}

.ai-section::before {
  content: '';
  position: absolute;
  top: 10%; left: -10%;
  width: 45vw; height: 45vw;
  max-width: 700px; max-height: 700px;
  background: radial-gradient(circle, rgba(0, 212, 255, 0.06) 0%, transparent 65%);
  filter: blur(70px);
  pointer-events: none;
  z-index: 0;
}

.ai-section::after {
  content: '';
  position: absolute;
  bottom: 10%; right: -10%;
  width: 40vw; height: 40vw;
  max-width: 600px; max-height: 600px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.05) 0%, transparent 65%);
  filter: blur(70px);
  pointer-events: none;
  z-index: 0;
}

.ai-container {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
}

/* ─── Header ──────────────────────────────────────────────────── */
.ai-header {
  text-align: center;
  max-width: 780px;
  margin: 0 auto 56px;
}

.ai-eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #00d4ff;
  margin-bottom: 14px;
  padding: 6px 14px;
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 999px;
}

.ai-eyebrow-sm {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #00d4ff;
  margin-bottom: 6px;
}

.ai-title {
  font-family: var(--font-display, 'Plus Jakarta Sans', sans-serif);
  font-size: clamp(28px, 4.2vw, 44px);
  font-weight: 800;
  line-height: 1.12;
  margin: 0 0 16px;
  color: var(--text-primary, #fff);
  letter-spacing: -0.02em;
}

.ai-title .gradient-text {
  background: linear-gradient(135deg, #00d4ff 0%, #0095ff 50%, #8b5cf6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  display: inline-block;
}

.ai-subtitle {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-secondary, rgba(255, 255, 255, 0.65));
  margin: 0;
}

/* ─── Grid 2 columnas ─────────────────────────────────────────── */
.ai-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.ai-left, .ai-right {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Card base ───────────────────────────────────────────────── */
.ai-card {
  background: linear-gradient(160deg,
    rgba(255, 255, 255, 0.035) 0%,
    rgba(255, 255, 255, 0.012) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  padding: 28px;
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* ─── Prompt card ─────────────────────────────────────────────── */
.ai-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #fff);
  margin-bottom: 10px;
}

.ai-label-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #0095ff, #00d4ff);
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 0 18px rgba(0, 149, 255, 0.35);
}

.ai-textarea {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: var(--text-primary, #fff);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.55;
  resize: vertical;
  min-height: 100px;
  transition: border-color 150ms ease, background 150ms ease;
}

.ai-textarea::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.ai-textarea:focus {
  outline: none;
  border-color: rgba(0, 149, 255, 0.5);
  background: rgba(0, 149, 255, 0.05);
}

/* ─── Chips ───────────────────────────────────────────────────── */
.ai-chip-section {
  margin: 14px 0 18px;
}

.ai-chip-hint {
  display: block;
  font-size: 12px;
  color: var(--text-secondary, rgba(255, 255, 255, 0.5));
  margin-bottom: 8px;
}

.ai-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-chip {
  padding: 7px 13px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  color: var(--text-secondary, rgba(255, 255, 255, 0.75));
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;
}

.ai-chip:hover {
  background: rgba(0, 149, 255, 0.08);
  border-color: rgba(0, 149, 255, 0.35);
  color: #fff;
  transform: translateY(-1px);
}

.ai-chip.active {
  background: rgba(0, 149, 255, 0.15);
  border-color: rgba(0, 149, 255, 0.5);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(0, 149, 255, 0.1);
}

/* ─── Generate button ─────────────────────────────────────────── */
.ai-generate-btn {
  width: 100%;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
}

.ai-generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-generate-spinner {
  display: none;
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: aiSpin 720ms linear infinite;
  position: absolute;
}

.ai-generate-btn.loading .ai-generate-label,
.ai-generate-btn.loading .ai-generate-arrow { opacity: 0; }

.ai-generate-btn.loading .ai-generate-spinner { display: inline-block; }

@keyframes aiSpin {
  to { transform: rotate(360deg); }
}

.ai-disclaimer {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
  margin: 10px 0 0;
}

/* ─── Result card ─────────────────────────────────────────────── */
.ai-result-card {
  min-height: 320px;
  position: relative;
  background: linear-gradient(160deg,
    rgba(255, 255, 255, 0.048) 0%,
    rgba(0, 149, 255, 0.018) 100%);
}

.ai-result-empty {
  text-align: center;
  padding: 40px 20px;
}

.ai-result-empty-ico {
  position: relative;
  width: 80px; height: 80px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}

.ai-pulse {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(0, 212, 255, 0.2) 0%, transparent 70%);
  border-radius: 50%;
  animation: aiPulse 2.4s ease-in-out infinite;
}

.ai-pulse-ring {
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 50%;
  animation: aiPulse 2.4s ease-in-out infinite 0.4s;
}

@keyframes aiPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%      { opacity: 0.9; transform: scale(1.1); }
}

.ai-result-empty h3 {
  font-family: var(--font-display, 'Plus Jakarta Sans', sans-serif);
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text-primary, #fff);
}

.ai-result-empty p {
  font-size: 14px;
  color: var(--text-secondary, rgba(255, 255, 255, 0.6));
  line-height: 1.55;
  max-width: 340px;
  margin: 0 auto;
}

/* ─── Loading skeleton ────────────────────────────────────────── */
.ai-result-loading.hidden,
.ai-result-content.hidden,
.ai-result-error.hidden,
.ai-result-empty.hidden,
.ai-cta-bar.hidden { display: none; }

.ai-skeleton {
  background: linear-gradient(90deg,
    rgba(255, 255, 255, 0.04) 0%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 100%);
  background-size: 200% 100%;
  border-radius: 8px;
  animation: aiShimmer 1.6s ease-in-out infinite;
}

@keyframes aiShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ai-sk-title { height: 24px; width: 60%; margin-bottom: 10px; }
.ai-sk-text  { height: 14px; width: 90%; margin-bottom: 20px; }
.ai-sk-card  { height: 90px; border-radius: 14px; }
.ai-skeleton-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ai-loading-text {
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-secondary, rgba(255, 255, 255, 0.6));
  text-align: center;
}

.ai-loading-dot {
  display: inline-block;
  width: 5px; height: 5px;
  margin: 0 1px;
  background: #00d4ff;
  border-radius: 50%;
  animation: aiDot 1.2s ease-in-out infinite;
}

.ai-loading-dot:nth-child(2) { animation-delay: 0.15s; }
.ai-loading-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes aiDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* ─── Result content ──────────────────────────────────────────── */
.ai-result-content {
  animation: aiFadeIn 400ms ease-out both;
}

@keyframes aiFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-result-intro {
  padding: 16px 18px;
  background: linear-gradient(135deg,
    rgba(0, 212, 255, 0.06) 0%,
    rgba(139, 92, 246, 0.04) 100%);
  border: 1px solid rgba(0, 212, 255, 0.15);
  border-radius: 14px;
  margin-bottom: 20px;
}

.ai-result-intro-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #00d4ff;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ai-result-intro p {
  font-size: 14.5px;
  color: var(--text-primary, rgba(255, 255, 255, 0.9));
  line-height: 1.6;
  margin: 0;
}

.ai-rooms {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.ai-room {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  padding: 16px 18px;
  transition: border-color 180ms ease, background 180ms ease;
}

.ai-room:hover {
  background: rgba(0, 149, 255, 0.04);
  border-color: rgba(0, 149, 255, 0.22);
}

.ai-room-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.ai-room-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  background: rgba(0, 149, 255, 0.1);
  border: 1px solid rgba(0, 149, 255, 0.2);
  border-radius: 10px;
  font-size: 16px;
  flex-shrink: 0;
}

.ai-room-title {
  font-family: var(--font-display, 'Plus Jakarta Sans', sans-serif);
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary, #fff);
}

.ai-room-subtitle {
  font-size: 12px;
  color: var(--text-secondary, rgba(255, 255, 255, 0.55));
  margin: 0;
}

.ai-devices {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-device {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-primary, rgba(255, 255, 255, 0.92));
}

.ai-device::before {
  content: '●';
  font-size: 7px;
  color: #00d4ff;
}

.ai-result-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(139, 92, 246, 0.05);
  border: 1px solid rgba(139, 92, 246, 0.18);
  border-radius: 14px;
  font-size: 13.5px;
  color: var(--text-primary, rgba(255, 255, 255, 0.9));
}

.ai-result-summary-ico {
  font-size: 20px;
  flex-shrink: 0;
}

/* ─── Result error ────────────────────────────────────────────── */
.ai-result-error {
  text-align: center;
  padding: 40px 20px;
}

.ai-error-ico {
  font-size: 36px;
  margin-bottom: 10px;
}

.ai-result-error h3 {
  font-family: var(--font-display, 'Plus Jakarta Sans', sans-serif);
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text-primary, #fff);
}

.ai-result-error p {
  font-size: 14px;
  color: var(--text-secondary, rgba(255, 255, 255, 0.65));
  margin: 0 0 16px;
}

/* ─── CTA bar ─────────────────────────────────────────────────── */
.ai-cta-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 22px;
  background: linear-gradient(135deg,
    rgba(0, 149, 255, 0.08) 0%,
    rgba(139, 92, 246, 0.08) 100%);
  border: 1px solid rgba(0, 149, 255, 0.22);
  border-radius: 20px;
  flex-wrap: wrap;
  animation: aiFadeIn 400ms 150ms ease-out both;
}

.ai-cta-text {
  flex: 1;
  min-width: 220px;
}

.ai-cta-text strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #fff);
  margin-bottom: 2px;
}

.ai-cta-text span {
  font-size: 13px;
  color: var(--text-secondary, rgba(255, 255, 255, 0.65));
}

.ai-cta-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-cta-actions .btn {
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ═══════════════════════════════════════════════════════════════
   HOME ASSISTANT DEMO
═══════════════════════════════════════════════════════════════ */

.ai-ha-card {
  padding: 0;
  overflow: hidden;
  position: sticky;
  top: 90px;
}

.ai-ha-header {
  padding: 24px 24px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-ha-header-txt h3 {
  font-family: var(--font-display, 'Plus Jakarta Sans', sans-serif);
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text-primary, #fff);
}

.ai-ha-header-txt p {
  font-size: 13px;
  color: var(--text-secondary, rgba(255, 255, 255, 0.6));
  margin: 0;
}

.ai-ha-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #22c55e;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.ai-ha-dot {
  width: 6px; height: 6px;
  background: #22c55e;
  border-radius: 50%;
  animation: aiHaDot 1.6s ease-in-out infinite;
  box-shadow: 0 0 6px #22c55e;
}

@keyframes aiHaDot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* ─── Home Assistant app frame ────────────────────────────────── */
.ai-ha-demo-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(0, 149, 255, 0.06), rgba(255, 255, 255, 0.015)),
    radial-gradient(520px 260px at 50% 24%, rgba(34, 197, 94, 0.09), transparent 72%);
}

.ai-ha-device {
  position: relative;
  width: min(100%, 430px);
  aspect-ratio: 10 / 15.6;
  min-height: 560px;
  max-height: 680px;
  background: #09111f;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 28px;
  box-shadow:
    0 34px 90px rgba(0, 0, 0, 0.52),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-ha-device::before {
  content: "Vista app real";
  position: absolute;
  right: 18px;
  top: 54px;
  z-index: 3;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid rgba(34, 197, 94, 0.28);
  color: #86efac;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  backdrop-filter: blur(12px);
}

.ai-ha-device-bar {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 15px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-ha-window-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.7);
  flex: 0 0 auto;
}

.ai-ha-window-dot:nth-child(1) { background: #f87171; }
.ai-ha-window-dot:nth-child(2) { background: #fbbf24; }
.ai-ha-window-dot:nth-child(3) { background: #34d399; }

.ai-ha-device-title {
  margin-left: 8px;
  min-width: 0;
  color: rgba(238, 242, 255, 0.66);
  font-size: 12px;
  font-weight: 700;
}

.ai-ha-screen {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #0a0f1a;
}

#ai-ha-demo {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #0a0f1a;
  transition: opacity 400ms ease;
}

#ai-ha-demo:not(.ready) { opacity: 0; }

.ai-ha-frame-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  background: #0a0f1a;
  transition: opacity 400ms ease;
  pointer-events: none;
}

.ai-ha-frame-loader.hidden { opacity: 0; }

.ai-ha-spin {
  width: 20px; height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: #00d4ff;
  border-radius: 50%;
  animation: aiSpin 900ms linear infinite;
}

.ai-ha-foot {
  padding: 18px 24px 22px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.ai-ha-feat {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ai-ha-feat > span {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.ai-ha-feat > div {
  min-width: 0;
}

.ai-ha-feat strong {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary, #fff);
  margin-bottom: 2px;
}

.ai-ha-feat span:not(:first-child) {
  font-size: 11.5px;
  color: var(--text-secondary, rgba(255, 255, 255, 0.55));
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════ */

@media (max-width: 1040px) {
  .ai-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .ai-ha-card {
    position: static;
  }
}

@media (max-width: 640px) {
  .ai-card { padding: 22px; }
  .ai-chip { font-size: 12px; padding: 6px 11px; }
  .ai-skeleton-group { grid-template-columns: 1fr; }
  .ai-ha-foot {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .ai-cta-bar { flex-direction: column; align-items: stretch; }
  .ai-cta-actions .btn { flex: 1; justify-content: center; }
  .ai-ha-demo-wrap { padding: 16px; }
  .ai-ha-device {
    width: 100%;
    min-height: 500px;
    border-radius: 22px;
  }
  .ai-ha-device::before {
    top: 50px;
    right: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-pulse, .ai-pulse-ring, .ai-ha-dot,
  .ai-loading-dot, .ai-skeleton, .ai-ha-spin,
  .ai-generate-spinner, .ai-result-content, .ai-cta-bar {
    animation: none !important;
  }
}
