/* ════════════════════════════════════════════════════════════
   AquaCore Contact Widget v2 — scoped .aqua-widget-*
   Tokens: --ocean-dark #0a3553, --ocean-deep #0e4a6f, --ocean-darker #072940,
           --sky #2a8fbd, --sky-light #3da5d4, --wave #7ec8e3, --wave-light #b8e2f2
   ════════════════════════════════════════════════════════════ */

.aqua-widget, .aqua-widget *, .aqua-widget *::before, .aqua-widget *::after { box-sizing: border-box; }
.aqua-widget { font-family: 'Outfit', system-ui, sans-serif; color: #0a3553; }

/* ── Sticky bar (stage 1) ─────────────────────────────────── */
.aqua-widget__bar {
    position: fixed; bottom: 20px; right: 20px; left: auto;
    max-width: 380px;
    background: linear-gradient(135deg, #0a3553 0%, #0e4a6f 100%);
    border: 1px solid rgba(184, 226, 242, .25);
    border-radius: 999px;
    padding: 10px 44px 10px 10px;
    box-shadow: 0 10px 32px rgba(10, 53, 83, .35), 0 0 0 1px rgba(126, 200, 227, .08);
    opacity: 0; transform: translateY(14px) scale(.96); pointer-events: none;
    transition: opacity .4s cubic-bezier(.4,0,.2,1),
                transform .4s cubic-bezier(.4,0,.2,1),
                bottom .35s cubic-bezier(.4,0,.2,1);
    z-index: 9990; backdrop-filter: blur(6px);
}
.aqua-widget__bar--show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.aqua-widget__bar--minimized { opacity: 0; transform: translateY(10px) scale(.94); pointer-events: none; }

.aqua-widget__bar-close {
    position: absolute; top: 50%; right: 14px; transform: translateY(-50%);
    width: 24px; height: 24px; padding: 0; line-height: 1;
    background: rgba(255,255,255,.08); border: none; border-radius: 50%;
    color: rgba(255,255,255,.7); font-size: 1rem; cursor: pointer;
    transition: background .2s, color .2s; z-index: 2;
}
.aqua-widget__bar-close:hover { background: rgba(255,255,255,.18); color: #fff; }

.aqua-widget__bar-btn {
    display: flex; align-items: center; gap: 12px;
    background: none; border: none; padding: 0; margin: 0;
    cursor: pointer; width: 100%; text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.aqua-widget__avatar {
    width: 44px; height: 44px; flex-shrink: 0;
    border-radius: 50%;
    background: rgba(184, 226, 242, .18);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.15rem; position: relative;
    animation: aquaWidgetPulse 2.6s ease-in-out infinite;
}
@keyframes aquaWidgetPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(184, 226, 242, .4); }
    50%      { box-shadow: 0 0 0 12px rgba(184, 226, 242, 0); }
}

.aqua-widget__dot {
    position: absolute; top: 1px; right: 1px;
    width: 11px; height: 11px; border-radius: 50%;
    border: 2px solid #0a3553;
}
.aqua-widget__dot--on  { background: #4ade80; box-shadow: 0 0 8px rgba(74, 222, 128, .6); }
.aqua-widget__dot--off { background: #f59e0b; }

.aqua-widget__bar-text {
    display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1;
    color: #fff;
}
.aqua-widget__msg {
    font-size: .92rem; font-weight: 600; line-height: 1.25;
    letter-spacing: .1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aqua-widget__reply {
    font-size: .72rem; font-weight: 400; color: rgba(184, 226, 242, .85);
    display: flex; align-items: center; gap: 5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aqua-widget__reply::before {
    content: ''; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0;
    background: currentColor;
}

/* ── Panel (stage 2) ──────────────────────────────────────── */
.aqua-widget__panel {
    position: fixed; bottom: 20px; right: 20px;
    width: 380px; max-width: calc(100vw - 32px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(10, 53, 83, .25), 0 0 0 1px rgba(10, 53, 83, .06);
    overflow: hidden;
    opacity: 0; transform: translateY(24px) scale(.92); pointer-events: none;
    transition: opacity .35s cubic-bezier(.4,0,.2,1),
                transform .35s cubic-bezier(.4,0,.2,1),
                bottom .35s cubic-bezier(.4,0,.2,1);
    z-index: 9991;
}
.aqua-widget__panel--open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* Header */
.aqua-widget__header {
    position: relative;
    background: linear-gradient(135deg, #072940 0%, #0e4a6f 100%);
    color: #fff;
    padding: 22px 56px 30px 24px;
}
.aqua-widget__header-inner { position: relative; z-index: 1; }
.aqua-widget__title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.3rem; font-weight: 700; margin: 0 0 4px;
    letter-spacing: -.3px; line-height: 1.2;
}
.aqua-widget__subtitle {
    font-size: .8rem; font-weight: 400; margin: 0;
    color: rgba(184, 226, 242, .9); letter-spacing: .2px;
}
.aqua-widget__close {
    position: absolute; top: 14px; right: 12px;
    width: 36px; height: 36px; padding: 0;
    background: rgba(255,255,255,.1); border: none; border-radius: 50%;
    color: rgba(255,255,255,.85); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s, color .2s;
    z-index: 5;
}
.aqua-widget__close:hover { background: rgba(255,255,255,.2); color: #fff; }
.aqua-widget__close:active { background: rgba(255,255,255,.28); }
.aqua-widget__close svg { pointer-events: none; transition: transform .2s; }
.aqua-widget__close:hover svg { transform: rotate(90deg); }
.aqua-widget__wave {
    position: absolute; left: 0; right: 0; bottom: -1px;
    width: 100%; height: 20px; display: block;
}

/* Body */
.aqua-widget__body {
    padding: 18px 24px 22px;
    max-height: calc(100vh - 180px); overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: rgba(10,53,83,.2) transparent;
}
.aqua-widget__body::-webkit-scrollbar { width: 6px; }
.aqua-widget__body::-webkit-scrollbar-thumb { background: rgba(10,53,83,.2); border-radius: 3px; }

/* Welcome bubble */
.aqua-widget__welcome {
    background: rgba(126, 200, 227, .14);
    color: #0a3553;
    font-size: .88rem; line-height: 1.5;
    padding: 12px 14px;
    border-radius: 14px;
    border-top-left-radius: 4px;
    margin-bottom: 16px;
    border: 1px solid rgba(126, 200, 227, .22);
}

/* Error banner */
.aqua-widget__error {
    position: relative;
    background: #fde7e7; color: #8a1a1a;
    font-size: .82rem; line-height: 1.4;
    padding: 10px 32px 10px 14px;
    border-radius: 10px; margin-bottom: 14px;
    border: 1px solid rgba(138, 26, 26, .15);
    animation: aquaWidgetSlideDown .25s ease-out;
}
@keyframes aquaWidgetSlideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.aqua-widget__error-close {
    position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
    width: 22px; height: 22px; padding: 0;
    background: none; border: none; color: inherit; opacity: .6;
    font-size: 1rem; cursor: pointer; border-radius: 50%;
    transition: opacity .2s, background .2s;
}
.aqua-widget__error-close:hover { opacity: 1; background: rgba(138, 26, 26, .08); }

/* Form */
.aqua-widget__form { display: flex; flex-direction: column; gap: 14px; }

.aqua-widget__field { position: relative; }
.aqua-widget__field input,
.aqua-widget__field textarea {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 2px solid rgba(10, 53, 83, .12);
    padding: 20px 0 8px;
    font-family: inherit; font-size: .92rem; color: #0a3553;
    outline: none; resize: none;
    transition: border-color .25s;
}
.aqua-widget__field textarea { min-height: 44px; max-height: 120px; }
.aqua-widget__field input::placeholder,
.aqua-widget__field textarea::placeholder { color: transparent; }

.aqua-widget__field label {
    position: absolute; left: 0; top: 20px;
    font-size: .92rem; color: #6a8da3;
    pointer-events: none;
    transition: transform .22s cubic-bezier(.4,0,.2,1), color .22s;
    transform-origin: left top;
}
.aqua-widget__field input:focus ~ label,
.aqua-widget__field textarea:focus ~ label,
.aqua-widget__field input:not(:placeholder-shown) ~ label,
.aqua-widget__field textarea:not(:placeholder-shown) ~ label {
    transform: translateY(-16px) scale(.78);
    color: #2a8fbd; font-weight: 500;
}
.aqua-widget__field input:focus,
.aqua-widget__field textarea:focus { border-bottom-color: #2a8fbd; }

.aqua-widget__field input[aria-invalid="true"],
.aqua-widget__field textarea[aria-invalid="true"] { border-bottom-color: #c54b4b; }
.aqua-widget__field input[aria-invalid="true"] ~ label,
.aqua-widget__field textarea[aria-invalid="true"] ~ label { color: #c54b4b; }

.aqua-widget__field-err {
    display: block; font-size: .72rem; color: #c54b4b;
    margin-top: 4px; min-height: 0;
    max-height: 0; overflow: hidden;
    transition: max-height .22s ease-out;
}
.aqua-widget__field-err.show { max-height: 30px; padding-top: 2px; }

/* GDPR */
.aqua-widget__gdpr {
    display: flex; align-items: flex-start; gap: 9px;
    font-size: .76rem; color: #5a6b7a; line-height: 1.4;
    cursor: pointer; user-select: none;
    margin-top: 4px;
}
.aqua-widget__gdpr input[type="checkbox"] {
    position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.aqua-widget__gdpr-box {
    width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px;
    border: 1.5px solid rgba(10, 53, 83, .28);
    border-radius: 4px; background: #fff;
    display: flex; align-items: center; justify-content: center;
    color: transparent;
    transition: background .2s, border-color .2s, color .2s;
}
.aqua-widget__gdpr input:checked + .aqua-widget__gdpr-box {
    background: #2a8fbd; border-color: #2a8fbd; color: #fff;
}
.aqua-widget__gdpr input:focus-visible + .aqua-widget__gdpr-box {
    box-shadow: 0 0 0 3px rgba(42, 143, 189, .22);
}
.aqua-widget__gdpr a { color: #2a8fbd; text-decoration: underline; }
.aqua-widget__gdpr a:hover { color: #1a6fa0; }

/* Submit */
.aqua-widget__submit {
    position: relative;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 13px 20px;
    background: linear-gradient(135deg, #2a8fbd, #3da5d4);
    color: #fff; border: none; border-radius: 999px;
    font-family: inherit; font-size: .95rem; font-weight: 600;
    letter-spacing: .2px; cursor: pointer;
    box-shadow: 0 6px 18px rgba(42, 143, 189, .35);
    transition: transform .22s cubic-bezier(.4,0,.2,1), box-shadow .22s, opacity .22s;
    margin-top: 6px;
}
.aqua-widget__submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(42, 143, 189, .45);
}
.aqua-widget__submit:hover:not(:disabled) .aqua-widget__submit-icon {
    transform: translateX(4px);
}
.aqua-widget__submit:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.aqua-widget__submit-icon { transition: transform .22s; }
.aqua-widget__submit-spinner {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
    display: none;
    animation: aquaWidgetSpin .8s linear infinite;
}
@keyframes aquaWidgetSpin { to { transform: rotate(360deg); } }
.aqua-widget__submit--loading .aqua-widget__submit-label,
.aqua-widget__submit--loading .aqua-widget__submit-icon { display: none; }
.aqua-widget__submit--loading .aqua-widget__submit-spinner { display: inline-block; }

/* Success */
.aqua-widget__success {
    text-align: center; padding: 28px 16px 20px;
    animation: aquaWidgetSuccessIn .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes aquaWidgetSuccessIn {
    from { opacity: 0; transform: scale(.88); }
    to   { opacity: 1; transform: scale(1); }
}
.aqua-widget__success-icon { color: #2a8fbd; margin-bottom: 10px; }
.aqua-widget__success-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.3rem; font-weight: 700; color: #0a3553;
    margin: 0 0 6px; letter-spacing: -.3px;
}
.aqua-widget__success-text {
    font-size: .88rem; color: #6a8da3; margin: 0 0 18px;
}
.aqua-widget__progress {
    height: 3px; background: rgba(10, 53, 83, .08);
    border-radius: 999px; overflow: hidden; margin: 0 auto; max-width: 200px;
}
.aqua-widget__progress span {
    display: block; height: 100%;
    background: linear-gradient(90deg, #2a8fbd, #7ec8e3);
    width: 100%;
}
.aqua-widget__progress--run span {
    animation: aquaWidgetCountdown 4s linear forwards;
}
@keyframes aquaWidgetCountdown { from { width: 100%; } to { width: 0%; } }

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 540px) {
    .aqua-widget__bar {
        right: 12px; bottom: 12px; left: 12px; max-width: none;
        padding: 9px 40px 9px 9px;
    }
    .aqua-widget__bar-close { right: 10px; }
    .aqua-widget__avatar { width: 40px; height: 40px; font-size: 1.05rem; }
    .aqua-widget__msg { font-size: .88rem; }
    .aqua-widget__reply { font-size: .7rem; }
    .aqua-widget__panel {
        right: 12px; left: 12px; bottom: 12px;
        width: auto; max-width: none;
    }
    .aqua-widget__header { padding: 20px 50px 26px 20px; }
    .aqua-widget__title { font-size: 1.2rem; }
    .aqua-widget__body { padding: 16px 20px 20px; }
}

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .aqua-widget__avatar { animation: none; }
    .aqua-widget__bar,
    .aqua-widget__panel,
    .aqua-widget__field label,
    .aqua-widget__submit,
    .aqua-widget__submit-icon,
    .aqua-widget__close,
    .aqua-widget__error,
    .aqua-widget__success { transition: none; animation: none; }
    .aqua-widget__progress--run span { animation-duration: .1s; }
}

/* ── Play nicely with site fixed elements (scroll-top, etc.) ── */
body.aqua-widget-active .scroll-top,
body.aqua-widget-active .back-to-top { bottom: 92px !important; }
