/* Contact widget — expand/collapse from FAB (macOS Dock feel) */

.contact-widget-root {
    position: fixed;
    right: 1.25rem;
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    z-index: 121;
    pointer-events: none;
    overflow: visible;
}

.contact-widget-stack {
    position: relative;
    width: 52px;
    height: 52px;
    pointer-events: auto;
    overflow: visible;
}

.contact-fab {
    position: absolute;
    right: 0;
    bottom: 0;
    z-index: 2;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: #000;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.contact-fab:hover { transform: scale(1.05); }
.contact-fab:active { transform: scale(0.96); }

.contact-widget-root.is-open .contact-fab {
    opacity: 0;
    transform: scale(0.85);
    pointer-events: none;
}

.contact-fab svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.contact-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 120;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.contact-modal-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.contact-modal {
    position: absolute;
    right: 0;
    bottom: 0;
    z-index: 1;
    width: min(420px, calc(100vw - 2.5rem));
    max-height: min(88vh, 640px);
    background: #fff;
    color: #171717;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: calc(100% - 26px) calc(100% - 26px);
    transform: scale(0.08);
    opacity: 0;
    pointer-events: none;
    border-radius: 26px;
    transition:
        transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.28s ease,
        border-radius 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.contact-widget-root:not(.is-open) .contact-modal {
    visibility: hidden;
}

.contact-widget-root.is-open .contact-modal {
    visibility: visible;
}

.contact-modal.is-expanded {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
    border-radius: 12px;
}

@media (max-width: 639px) {
    .contact-modal {
        width: calc(100vw - 2.5rem);
        max-height: 88vh;
    }

    .contact-modal.is-expanded {
        border-radius: 16px;
    }
}

.contact-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
}

.contact-modal-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.contact-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6e6e6e;
    border-radius: 50%;
}

.contact-modal-close:hover { background: #f3f3f3; }

.contact-modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.contact-widget-form label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6e6e6e;
    margin-bottom: 0.35rem;
}

.contact-widget-form input,
.contact-widget-form select,
.contact-widget-form textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.85rem;
    border: 1px solid #d0d0d0;
    background: #fff;
    color: #171717;
    font: inherit;
    font-size: 14px;
    border-radius: 0;
}

.contact-widget-form input:focus,
.contact-widget-form select:focus,
.contact-widget-form textarea:focus {
    outline: none;
    border-color: #171717;
}

.contact-widget-form textarea {
    min-height: 96px;
    resize: vertical;
}

.contact-widget-form .hp-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.contact-widget-form .btn-send {
    width: 100%;
    padding: 0.85rem 1rem;
    border: none;
    background: #000;
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.contact-widget-form .btn-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.contact-widget-status {
    font-size: 12px;
    margin-top: 0.75rem;
    line-height: 1.5;
    color: #6e6e6e;
}

.contact-widget-status.is-success {
    color: #171717;
}

.contact-widget-status.is-error {
    color: #c0392b;
}

.contact-widget-note {
    font-size: 11px;
    color: #6e6e6e;
    margin-top: 0.5rem;
    line-height: 1.45;
}

.contact-widget-success {
    text-align: center;
    padding: 1.5rem 0.5rem 0.75rem;
    animation: contact-success-in 0.35s ease;
}

.contact-success-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: #171717;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contact-success-title {
    margin: 0 0 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.contact-success-message {
    margin: 0 0 0.75rem;
    font-size: 14px;
    line-height: 1.55;
    color: #171717;
}

.contact-success-note {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: #6e6e6e;
}

@keyframes contact-success-in {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

[data-theme="dark"] .contact-success-icon {
    background: #fff;
    color: #000;
}

[data-theme="dark"] .contact-success-message {
    color: #f5f5f5;
}

@media (prefers-reduced-motion: reduce) {
    .contact-widget-success {
        animation: none;
    }
}

body.doc-page .contact-widget-root,
body.legal-doc .contact-widget-root {
    bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 639px) {
    body.doc-page .contact-widget-root,
    body.legal-doc .contact-widget-root {
        bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
    }
}

[data-theme="dark"] .contact-fab {
    background: #fff;
    color: #000;
}

[data-theme="dark"] .contact-modal {
    background: #111;
    color: #f5f5f5;
}

[data-theme="dark"] .contact-modal-header {
    border-bottom-color: #333;
}

[data-theme="dark"] .contact-widget-form input,
[data-theme="dark"] .contact-widget-form select,
[data-theme="dark"] .contact-widget-form textarea {
    background: #000;
    border-color: #444;
    color: #f5f5f5;
}

[data-theme="dark"] .contact-widget-form .btn-send {
    background: #fff;
    color: #000;
}

@media (prefers-reduced-motion: reduce) {
    .contact-fab,
    .contact-modal,
    .contact-modal-overlay {
        transition: none !important;
    }
}
