/* =========================================================
   Estudio solar en 4 pasos + asistente de chat
   ========================================================= */

.study-sec__inner { max-width: 1180px; margin: 0 auto; }
.study-sec__head { text-align: center; max-width: 52rem; margin: 0 auto 3.2rem; }
.study-sec__head > p:not(.label) { color: var(--muted); font-size: 1.1rem; margin: 1.4rem auto 0; max-width: 40rem; }

.study { position: relative; border-radius: 32px; padding: clamp(1.4rem, 3.5vw, 3rem); background: rgba(4,16,26,.55); }
.study__steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.study__steps li { display: flex; align-items: center; gap: .7rem; color: var(--muted); font-size: .9rem; transition: color .4s; }
.study__steps li span { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); font-family: "JetBrains Mono", monospace; font-size: .8rem; transition: all .5s var(--ease); }
.study__steps li.is-current { color: var(--cream); }
.study__steps li.is-current span { background: var(--mint); color: var(--ink); border-color: var(--mint); box-shadow: 0 0 0 6px rgba(139,240,181,.14); }
.study__steps li.is-done span { background: rgba(139,240,181,.15); color: var(--mint); border-color: rgba(139,240,181,.4); }
.study__bar { height: 2px; background: var(--line); margin: 1.2rem 0 2.4rem; border-radius: 2px; overflow: hidden; }
.study__bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--mint), var(--sun)); transition: width .8s var(--ease); }

.study__pane { display: none; }
.study__pane.is-active { display: block; animation: paneIn .7s var(--ease) both; }
@keyframes paneIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.study__h { font-family: var(--f-display); font-weight: 400; font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.05; margin: 0 0 .6rem; letter-spacing: -.015em; }
.study__p { color: var(--muted); margin: 0 0 1.6rem; max-width: 46rem; }
.study__err { color: #ffb3b3; font-size: .92rem; margin: .8rem 0 0; min-height: 1.2em; }
.study__err:empty { min-height: 0; margin: 0; }
.study__hint { font-size: .85rem; color: var(--muted); margin: .8rem 0 0; }
.study__privacy { display: flex; gap: .7rem; align-items: flex-start; font-size: .85rem; color: var(--muted); margin: 1.2rem 0 .6rem; max-width: 46rem; }
.study__privacy svg { width: 20px; flex: none; color: var(--mint); margin-top: .1rem; }
.study__nav { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 2rem; flex-wrap: wrap; }
.btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.btn:disabled::before { display: none; }
.btn.is-loading span::after { content: ""; display: inline-block; width: 14px; height: 14px; margin-left: .6rem; vertical-align: -2px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

.linkbtn { color: var(--mint); font-size: .92rem; text-decoration: underline; text-underline-offset: 4px; text-decoration-color: rgba(139,240,181,.4); padding: .3rem 0; }
.linkbtn:hover { text-decoration-color: var(--mint); }
.chip { padding: .5rem .9rem; border-radius: 99px; font-size: .82rem; background: rgba(4,16,26,.8); border: 1px solid var(--line); backdrop-filter: blur(6px); transition: border-color .3s; }
.chip:hover { border-color: var(--mint); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field--select select { width: 100%; font: inherit; color: var(--cream); background: rgba(4,16,26,.45); border: 1px solid var(--line); border-radius: 14px; padding: 1.45rem 1.1rem .6rem; outline: none; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%238bf0b5' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; background-size: 18px; }
.field--select select option { background: var(--navy); }
.field--select label { transform: translateY(-.62rem) scale(.78); color: var(--mint); }
.field--select select:focus { border-color: var(--mint); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Drop zone */
.drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; text-align: center; padding: 2.6rem 1.4rem; border-radius: 22px; border: 1.5px dashed rgba(139,240,181,.38); background: radial-gradient(80% 120% at 50% 0%, rgba(23,132,90,.18), transparent 70%), rgba(4,16,26,.35); cursor: pointer; transition: border-color .3s, background-color .3s, transform .5s var(--ease); }
.drop:hover, .drop.is-over { border-color: var(--mint); background-color: rgba(139,240,181,.06); transform: translateY(-2px); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop__icon { width: 58px; height: 58px; color: var(--mint); padding: 10px; border-radius: 16px; background: rgba(139,240,181,.08); }
.drop__t { font-size: 1.05rem; } .drop__t b { color: var(--mint); font-weight: 600; }
.drop__s { font-size: .82rem; color: var(--muted); }
.drop[hidden] { display: none; }

.reading { display: flex; align-items: center; gap: 1.4rem; padding: 1.8rem; border-radius: 22px; background: rgba(139,240,181,.06); border: 1px solid rgba(139,240,181,.25); }
.reading[hidden] { display: none; }
.reading p { margin: 0; } .reading span { color: var(--muted); font-size: .9rem; }
.reading__scan { position: relative; width: 56px; height: 70px; flex: none; border-radius: 8px; border: 1.5px solid rgba(139,240,181,.6); background: repeating-linear-gradient(transparent 0 9px, rgba(139,240,181,.18) 9px 10px); overflow: hidden; }
.reading__scan i { position: absolute; left: 0; right: 0; height: 3px; background: var(--mint); box-shadow: 0 0 14px var(--mint); animation: scan 1.4s ease-in-out infinite alternate; }
@keyframes scan { from { top: 4%; } to { top: 92%; } }

.bill-data { margin-top: 1.4rem; padding: 1.4rem; border-radius: 20px; border: 1px solid var(--line); background: rgba(7,27,43,.6); animation: paneIn .6s var(--ease) both; }
.bill-data[hidden] { display: none; }
.bill-data__badge { display: inline-block; font-family: "JetBrains Mono", monospace; font-size: .74rem; letter-spacing: .04em; padding: .35rem .7rem; border-radius: 99px; margin-bottom: 1rem; border: 1px solid var(--line); color: var(--muted); }
.bill-data__badge.is-auto { color: var(--ink); background: var(--mint); border-color: var(--mint); }

/* Address + map */
.addr { display: grid; grid-template-columns: 1fr auto; gap: .8rem; align-items: stretch; }
.addr .btn { height: 100%; border-radius: 14px; }
.addr__results { list-style: none; margin: .6rem 0 0; padding: .4rem; border-radius: 14px; border: 1px solid var(--line); background: rgba(4,16,26,.9); max-height: 220px; overflow: auto; }
.addr__results[hidden] { display: none; }
.addr__results button { width: 100%; text-align: left; padding: .7rem .8rem; border-radius: 10px; font-size: .88rem; color: var(--cream); }
.addr__results button:hover, .addr__results button:focus-visible { background: rgba(139,240,181,.1); }
.mapwrap { position: relative; margin-top: 1rem; border-radius: 22px; overflow: hidden; border: 1px solid var(--line); }
.map { height: clamp(320px, 52vh, 480px); background: #0b2233; cursor: crosshair; }
.map__tools { position: absolute; top: .8rem; right: .8rem; z-index: 500; display: flex; gap: .5rem; }
.map__area { position: absolute; left: .8rem; bottom: .8rem; z-index: 500; padding: .6rem .9rem; border-radius: 12px; font-size: .85rem; }
.map__area b { font-family: var(--f-display); font-size: 1.4rem; color: var(--mint); font-weight: 400; }
.map__help { position: absolute; top: .8rem; left: 3.6rem; z-index: 500; padding: .45rem .8rem; border-radius: 99px; font-size: .8rem; background: rgba(4,16,26,.82); border: 1px solid var(--line); pointer-events: none; max-width: calc(100% - 15rem); }
.map__help.is-warn { border-color: var(--sun); color: var(--sun); }
.leaflet-container { font-family: var(--f-body); }
.leaflet-control-attribution { font-size: 10px; background: rgba(4,16,26,.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--mint) !important; }
.leaflet-bar a { background: rgba(4,16,26,.88) !important; color: var(--cream) !important; border-color: var(--line) !important; }

.roof { display: flex; flex-wrap: wrap; gap: 1.4rem 2.4rem; margin-top: 1.4rem; }
.roof [hidden] { display: none; }
.chips--sm span { padding: .5rem .9rem; font-size: .85rem; }
.roof__manual { margin-top: 1rem; display: grid; gap: .7rem; max-width: 26rem; }
.roof__manual .field[hidden] { display: none; }
.roof__fit { margin-top: 1.2rem; padding: 1rem 1.2rem; border-radius: 16px; background: rgba(139,240,181,.07); border: 1px solid rgba(139,240,181,.2); color: var(--muted); }
.roof__fit b { color: var(--mint); font-weight: 600; }

/* Email gate */
.gate { max-width: 40rem; margin: 0 auto; text-align: center; }
.gate .study__p { margin-left: auto; margin-right: auto; }
.gate form { text-align: left; display: grid; gap: 1rem; }
.gate__preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin-bottom: 2rem; }
.gate__blur { padding: 1.1rem .8rem; border-radius: 16px; background: rgba(139,240,181,.06); border: 1px solid rgba(139,240,181,.18); display: flex; flex-direction: column; gap: .2rem; }
.gate__blur b { font-family: var(--f-display); font-size: 1.8rem; font-weight: 400; color: var(--mint); filter: blur(5px); animation: blurPulse 2.4s ease-in-out infinite; }
.gate__blur span { font-size: .78rem; color: var(--muted); }
@keyframes blurPulse { 50% { filter: blur(8px); opacity: .7; } }

/* Report */
.report__top { display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem; flex-wrap: wrap; padding-bottom: 1.8rem; border-bottom: 1px solid var(--line); }
.report__k { font-family: "JetBrains Mono", monospace; font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--mint); margin: 0 0 .6rem; }
.report__h { font-family: var(--f-display); font-weight: 400; font-size: clamp(1.8rem, 3.4vw, 2.8rem); line-height: 1.05; margin: 0; max-width: 18ch; }
.report__addr { color: var(--muted); font-size: .88rem; margin: .6rem 0 0; }
.report__big { text-align: right; }
.report__big b { display: block; font-family: var(--f-display); font-weight: 300; font-size: clamp(3rem, 7vw, 5.4rem); line-height: .95; color: var(--mint); letter-spacing: -.03em; }
.report__big span { color: var(--muted); font-size: .9rem; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; margin: 1.8rem 0; }
.kpis div { background: rgba(7,27,43,.92); padding: 1.2rem; display: flex; flex-direction: column; gap: .15rem; }
.kpis span { font-size: .78rem; color: var(--muted); }
.kpis b { font-family: var(--f-display); font-weight: 400; font-size: 1.9rem; line-height: 1.1; }
.kpis small { font-size: .78rem; color: var(--muted); }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.chart { margin: 0; padding: 1.2rem; border-radius: 20px; border: 1px solid var(--line); background: rgba(7,27,43,.6); }
.chart figcaption { font-size: .85rem; color: var(--muted); margin-bottom: .6rem; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.c-grid { stroke: rgba(234,242,236,.08); }
.c-ax { fill: rgba(234,242,236,.5); font-size: 12px; font-family: "JetBrains Mono", monospace; }
.c-line { fill: none; stroke: var(--mint); stroke-width: 3; stroke-linecap: round; }
.c-inv { stroke: var(--sun); stroke-dasharray: 6 6; stroke-width: 1.5; }
.c-lbl { fill: var(--sun); font-size: 12px; font-family: "JetBrains Mono", monospace; }
.c-dot { fill: var(--sun); stroke: var(--ink); stroke-width: 3; }
.c-bar-a { fill: var(--mint); transform-origin: bottom; transform-box: fill-box; animation: barUp .9s var(--ease) both; animation-delay: var(--d, 0ms); }
.c-bar-b { fill: rgba(234,242,236,.22); }
@keyframes barUp { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.legend { display: flex; align-items: center; gap: .5rem; font-size: .78rem; color: var(--muted); margin-top: .4rem; }
.lg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-left: .6rem; }
.lg--a { background: var(--mint); } .lg--b { background: rgba(234,242,236,.22); }
.assume { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.assume details { border-radius: 18px; border: 1px solid var(--line); padding: 1rem 1.2rem; background: rgba(7,27,43,.45); }
.assume summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
.assume summary::after { content: "+"; color: var(--mint); font-size: 1.2rem; line-height: 1; transition: transform .4s var(--ease); }
.assume details[open] summary::after { transform: rotate(45deg); }
.assume summary::-webkit-details-marker { display: none; }
.assume dl { margin: .8rem 0 0; display: grid; gap: .5rem; }
.assume dl div { display: grid; grid-template-columns: 42% 1fr; gap: .8rem; font-size: .85rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.assume dt { color: var(--muted); } .assume dd { margin: 0; }
.report__disclaimer { font-size: .82rem; color: var(--muted); margin: 1.4rem 0 .4rem; padding: .9rem 1rem; border-left: 2px solid var(--sun); background: rgba(247,210,30,.05); border-radius: 0 10px 10px 0; }
.report__pay { font-size: .95rem; margin: 1rem 0 0; } .report__pay b { color: var(--mint); font-weight: 600; }
.report__ctas { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-top: 1.6rem; }

.contact__list--row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 2rem; margin-top: 3rem; border-top: 1px solid var(--line); }
.contact__list--row li { grid-template-columns: 1fr; gap: .3rem; }
.contact__list--row a, .contact__list--row p { font-size: 1.1rem; }

@media (max-width: 900px) {
  .study__steps b { display: none; }
  .study__steps li { justify-content: center; }
  .grid2, .charts, .assume, .contact__list--row { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .report__big { text-align: left; }
  .gate__preview { grid-template-columns: 1fr 1fr 1fr; gap: .5rem; }
  .gate__blur b { font-size: 1.3rem; }
  .addr { grid-template-columns: 1fr; }
  .map__help { left: .8rem; top: auto; bottom: 4rem; max-width: calc(100% - 1.6rem); }
}

/* =========================================================
   Asistente de chat
   ========================================================= */
.chatw { position: fixed; right: clamp(.8rem, 2vw, 1.6rem); bottom: clamp(.8rem, 2vw, 1.6rem); z-index: 140; }
.chatw__fab { display: flex; align-items: center; gap: .7rem; padding: .55rem 1.1rem .55rem .55rem; border-radius: 99px; background: var(--navy); border: 1px solid rgba(139,240,181,.35); box-shadow: 0 20px 50px -18px rgba(0,0,0,.7), 0 0 0 0 rgba(139,240,181,.4); transition: transform .5s var(--ease), box-shadow .5s; animation: fabPing 3.5s ease-out 4s 2; }
.chatw__fab:hover { transform: translateY(-3px); }
@keyframes fabPing { 0% { box-shadow: 0 20px 50px -18px rgba(0,0,0,.7), 0 0 0 0 rgba(139,240,181,.45); } 70%, 100% { box-shadow: 0 20px 50px -18px rgba(0,0,0,.7), 0 0 0 18px rgba(139,240,181,0); } }
.chatw__fabt { font-size: .9rem; } .chatw__fabt b { color: var(--mint); }
.chatw__sun { width: 38px; height: 38px; border-radius: 50%; flex: none; background: radial-gradient(circle at 50% 50%, #157a3a 0 58%, #f7d21e 60%); position: relative; }
.chatw__sun::after { content: ""; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M36 12 20 35h11l-4 17 17-24H33z' fill='%23F7D21E'/%3E%3C/svg%3E") center/70% no-repeat; }
.chatw__sun--sm { width: 32px; height: 32px; }
.chatw.is-open .chatw__fab { display: none; }

.chatw__panel { width: min(400px, calc(100vw - 1.6rem)); height: min(600px, calc(100vh - 2rem)); height: min(600px, calc(100dvh - 2rem)); border-radius: 24px; display: flex; flex-direction: column; overflow: hidden; background: rgba(7,27,43,.94); animation: chatIn .5s var(--ease) both; transform-origin: bottom right; }
.chatw__panel[hidden] { display: none; }
@keyframes chatIn { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
.chatw__head { display: flex; align-items: center; gap: .8rem; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.chatw__head div { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.chatw__head small { color: var(--muted); font-size: .76rem; }
.chatw__close { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; }
.chatw__close:hover { background: rgba(234,242,236,.08); }
.chatw__close svg { width: 18px; }
.chatw__log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; overscroll-behavior: contain; }
.msg { max-width: 88%; padding: .75rem .95rem; border-radius: 16px; font-size: .92rem; line-height: 1.5; animation: paneIn .4s var(--ease) both; }
.msg p { margin: 0 0 .5rem; } .msg p:last-child { margin: 0; }
.msg ul, .msg ol { margin: .3rem 0 .5rem; padding-left: 1.2rem; }
.msg--bot { align-self: flex-start; background: rgba(139,240,181,.08); border: 1px solid rgba(139,240,181,.16); border-bottom-left-radius: 6px; }
.msg--me { align-self: flex-end; background: var(--mint); color: var(--ink); border-bottom-right-radius: 6px; }
.msg--err { align-self: flex-start; background: rgba(255,143,143,.1); border: 1px solid rgba(255,143,143,.3); }
.msg strong { color: var(--mint); }
.msg a { color: var(--mint); text-decoration: underline; }
.typing { display: inline-flex; gap: 4px; padding: .9rem 1rem; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); animation: typing 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
.chatw__sugg { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1rem .8rem; }
.chatw__sugg[hidden] { display: none; }
.chatw__sugg button { font-size: .8rem; padding: .45rem .75rem; border-radius: 99px; border: 1px solid rgba(139,240,181,.3); color: var(--mint); text-align: left; transition: background .3s; }
.chatw__sugg button:hover { background: rgba(139,240,181,.1); }
.chatw__form { display: flex; gap: .5rem; padding: .8rem; border-top: 1px solid var(--line); }
.chatw__form textarea { flex: 1; resize: none; font: inherit; font-size: .95rem; color: var(--cream); background: rgba(4,16,26,.6); border: 1px solid var(--line); border-radius: 14px; padding: .7rem .9rem; max-height: 120px; outline: none; overflow-y: hidden; }
.chatw__form textarea:focus { border-color: var(--mint); }
.chatw__send { width: 46px; border-radius: 14px; background: var(--mint); color: var(--ink); display: grid; place-items: center; flex: none; }
.chatw__send svg { width: 20px; }
.chatw__send:disabled { opacity: .5; }
.chatw__legal { font-size: .7rem; color: var(--muted); text-align: center; margin: 0; padding: 0 1rem .7rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 560px) {
  .chatw__fabt { display: none; }
  .chatw__fab { padding: .45rem; }
  .chatw__sun { width: 46px; height: 46px; }
  .chatw.is-open { left: 0; right: 0; bottom: 0; }
  .chatw__panel { width: 100%; height: 100dvh; height: 100vh; border-radius: 0; }
}

/* Impresión del estudio (Guardar en PDF) */
@media print {
  body { background: #fff; color: #071b2d; }
  body > *:not(main), main > *:not(#contacto), .study-sec__head, .study__steps, .study__bar, .contact__list, .contact__bg, .report__ctas, .grain, .splash, .chatw { display: none !important; }
  .study { background: none; border: 0; box-shadow: none; padding: 0; }
  .study__pane { display: none !important; } .study__pane[data-pane="4"] { display: block !important; }
  .report__big b, .kpis b, .report__k { color: #157a3a; }
  .kpis div, .chart, .assume details { background: #fff; }
  .kpis span, .kpis small, .assume dt, .report__addr, .report__disclaimer, .c-ax { color: #444; fill: #444; }
  .assume details { break-inside: avoid; } .assume details:not([open]) dl { display: grid; }
}
