/**
 * Noorin Floating Contact Component
 * Version: 1.1.0
 */

#fc-wrapper {
    --fc-primary: #003048;
    --fc-primary-hover: #01425f;
    --fc-text: #23313d;
    --fc-muted: #6b7280;
    --fc-border: #e8edf2;
    --fc-bg: #fff;
    --fc-radius: 18px;
    --fc-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
    --fc-transition: 0.25s ease;

    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999999;
    direction: rtl;
    font-family: inherit;
    line-height: 1.5;
    pointer-events: none;
    isolation: isolate;
}

#fc-wrapper,
#fc-wrapper * {
    box-sizing: border-box;
}

body.fc-contact-open {
    overscroll-behavior: none;
}

/* Floating button */
#fc-wrapper .fc-button {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    min-width: 64px;
    height: 64px;
    min-height: 64px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    appearance: none;
    background: var(--fc-primary);
    color: #fff;
    box-shadow: var(--fc-shadow);
    cursor: pointer;
    pointer-events: auto;
    transition: transform var(--fc-transition), background-color var(--fc-transition);
}

#fc-wrapper .fc-button::before {
    content: "";
    position: absolute;
    inset: -6px;
    border: 2px solid rgba(0, 48, 72, 0.25);
    border-radius: inherit;
    pointer-events: none;
    animation: fc-ripple 2.5s infinite;
}

#fc-wrapper .fc-button svg {
    display: block;
    width: 28px;
    height: 28px;
    fill: currentColor;
    pointer-events: none;
}

/* Popup */
#fc-wrapper .fc-popup {
    position: absolute;
    right: 0;
    bottom: 82px;
    z-index: 2;
    width: min(340px, calc(100vw - 32px));
    max-height: calc(100vh - 130px);
    max-height: calc(100dvh - 130px);
    overflow: hidden;
    border: 1px solid var(--fc-border);
    border-radius: var(--fc-radius);
    background: var(--fc-bg);
    box-shadow: var(--fc-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(18px) scale(0.97);
    transform-origin: bottom right;
    pointer-events: none;
    transition:
        opacity var(--fc-transition),
        visibility var(--fc-transition),
        transform var(--fc-transition);
}

#fc-wrapper .fc-popup.is-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
#fc-wrapper .fc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    background: var(--fc-primary);
    color: #fff;
}

#fc-wrapper .fc-heading {
    margin: 0;
    padding: 0;
    color: inherit;
    font: inherit;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.4;
}

#fc-wrapper .fc-close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    appearance: none;
    background: transparent;
    color: #fff;
    font: inherit;
    font-size: 27px;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

/* Content */
#fc-wrapper .fc-content {
    max-height: min(420px, calc(100vh - 210px));
    max-height: min(420px, calc(100dvh - 210px));
    padding: 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #c8d3dc transparent;
}

#fc-wrapper .fc-content::-webkit-scrollbar {
    width: 7px;
}

#fc-wrapper .fc-content::-webkit-scrollbar-track {
    background: transparent;
}

#fc-wrapper .fc-content::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: #cbd5df;
}

/* Contact item */
#fc-wrapper .fc-item {
    display: block;
    margin: 0 0 12px;
    padding: 15px;
    border: 1px solid var(--fc-border);
    border-radius: 14px;
    background: #fff;
    color: var(--fc-text);
    text-decoration: none;
    line-height: 1.5;
    transition:
        transform var(--fc-transition),
        border-color var(--fc-transition),
        background-color var(--fc-transition);
}

#fc-wrapper .fc-item:last-child {
    margin-bottom: 0;
}

#fc-wrapper .fc-title,
#fc-wrapper .fc-name,
#fc-wrapper .fc-value {
    display: block;
}

#fc-wrapper .fc-title {
    color: var(--fc-primary);
    font-size: 14px;
    font-weight: 700;
}

#fc-wrapper .fc-name {
    margin-top: 5px;
    color: var(--fc-muted);
    font-size: 13px;
}

#fc-wrapper .fc-value {
    margin-top: 7px;
    color: #1e2936;
    font-size: 18px;
    font-weight: 700;
    direction: ltr;
    text-align: left;
    unicode-bidi: isolate;
}

#fc-wrapper .fc-item--whatsapp {
    border-color: #d8f2df;
}

/* Overlay */
#fc-wrapper .fc-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--fc-transition), visibility var(--fc-transition);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

#fc-wrapper .fc-overlay.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Interaction */
@media (hover: hover) and (pointer: fine) {
    #fc-wrapper .fc-button:hover {
        background: var(--fc-primary-hover);
        transform: translateY(-4px);
    }

    #fc-wrapper .fc-close:hover {
        background: rgba(255, 255, 255, 0.1);
        transform: rotate(90deg);
    }

    #fc-wrapper .fc-item:hover {
        border-color: #dbe7ef;
        background: #f8fbfd;
        transform: translateY(-2px);
    }

    #fc-wrapper .fc-item--whatsapp:hover {
        background: #f4fff7;
    }
}

#fc-wrapper .fc-button:focus-visible,
#fc-wrapper .fc-close:focus-visible,
#fc-wrapper .fc-item:focus-visible {
    outline: 3px solid rgba(0, 48, 72, 0.32);
    outline-offset: 3px;
}

#fc-wrapper .fc-header .fc-close:focus-visible {
    outline-color: rgba(255, 255, 255, 0.75);
}

@keyframes fc-ripple {
    0% {
        opacity: 0.8;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(1.55);
    }
}

/* Mobile */
@media (max-width: 768px) {
    #fc-wrapper {
        right: max(16px, env(safe-area-inset-right));
        bottom: max(16px, env(safe-area-inset-bottom));
    }

    #fc-wrapper .fc-button {
        width: 58px;
        min-width: 58px;
        height: 58px;
        min-height: 58px;
    }

    #fc-wrapper .fc-button svg {
        width: 24px;
        height: 24px;
    }

    #fc-wrapper .fc-popup {
        position: fixed;
        right: max(16px, env(safe-area-inset-right));
        left: max(16px, env(safe-area-inset-left));
        bottom: calc(max(16px, env(safe-area-inset-bottom)) + 72px);
        width: auto;
        max-height: calc(100vh - 112px - env(safe-area-inset-bottom));
        max-height: calc(100dvh - 112px - env(safe-area-inset-bottom));
        transform-origin: bottom center;
    }

    #fc-wrapper .fc-header {
        padding: 16px;
    }

    #fc-wrapper .fc-content {
        max-height: calc(100vh - 190px - env(safe-area-inset-bottom));
        max-height: calc(100dvh - 190px - env(safe-area-inset-bottom));
        padding: 14px;
    }

    #fc-wrapper .fc-item {
        padding: 14px;
    }
}

@media (max-width: 420px) {
    #fc-wrapper .fc-popup {
        right: max(12px, env(safe-area-inset-right));
        left: max(12px, env(safe-area-inset-left));
    }

    #fc-wrapper .fc-title {
        font-size: 13px;
    }

    #fc-wrapper .fc-value {
        font-size: 16px;
    }
}

@media (min-width: 1440px) {
    #fc-wrapper {
        right: 32px;
        bottom: 32px;
    }
}

/* Restrict reduced motion to this component only. */
@media (prefers-reduced-motion: reduce) {
    #fc-wrapper .fc-button,
    #fc-wrapper .fc-button::before,
    #fc-wrapper .fc-popup,
    #fc-wrapper .fc-overlay,
    #fc-wrapper .fc-close,
    #fc-wrapper .fc-item {
        animation: none !important;
        transition: none !important;
    }
}
