/* ==========================================================
   QUICK CONTACT BUTTONS — BASE STYLES
   Mobile-first, optimized
   ========================================================== */

/* =========================
   ROOT CONTAINER
   ========================= */
.qcb {
    position: fixed;
    z-index: 999999;
    pointer-events: none;

    font-size: var(--qcb-font-size);
    color: var(--qcb-font-color);
}

/* =========================
   BUTTON RAIL
   ========================= */
.qcb-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    column-gap: var(--qcb-button-gap);
    row-gap: calc(var(--qcb-button-gap) * 0.25);
    pointer-events: auto;
}

.qcb-buttons .qcb-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    column-gap: var(--qcb-button-gap);
    row-gap: calc(var(--qcb-button-gap) * 0.25);
    pointer-events: auto;
    padding: calc(var(--qcb-button-gap) * 0.75)
             calc(var(--qcb-button-gap) * 0.75);    
}

/* =========================
   POSITIONS & STACKING
   ========================= */
.qcb-pos-bottom-right { right: 0; bottom: 0; margin: 1rem 1.25rem; }
.qcb-pos-bottom-left  { left: 0; bottom: 0; margin: 1rem 1.25rem; }
.qcb-pos-bottom-center {
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
}

/* Vertical stack for edges — centered horizontally */
.qcb.qcb-pos-bottom-right .qcb-buttons,
.qcb.qcb-pos-bottom-left  .qcb-buttons {
    flex-direction: column;
    gap: calc(var(--qcb-button-gap) * 0.65);
    align-items: center; /* centered horizontally */
}

/* Center stays horizontal */
.qcb.qcb-pos-bottom-center .qcb-buttons {
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
}

/* =========================
   RAIL ALIGNMENT — MOBILE-FIRST
   ========================= */
/* Vertical stack for edges — centered horizontally */
.qcb.qcb-pos-bottom-right .qcb-buttons .qcb-inner,
.qcb.qcb-pos-bottom-left  .qcb-buttons .qcb-inner {
    flex-direction: column;
    justify-content: center;
    align-items: center; /* centered horizontally */
    gap: calc(var(--qcb-button-gap) * 0.65);
}

/* Center stays horizontal */
.qcb.qcb-pos-bottom-center .qcb-buttons .qcb-inner {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

/* Auto compact vertical buttons */
.qcb.qcb-pos-bottom-right .qcb-btn,
.qcb.qcb-pos-bottom-left  .qcb-btn {
    flex-direction: column;
    text-align: center;
    padding: calc(var(--qcb-button-gap) * 0.35);
}

.qcb.qcb-pos-bottom-right .qcb-label,
.qcb.qcb-pos-bottom-left  .qcb-label {
    font-size: calc(var(--qcb-font-size) * 0.85);
}

/* =========================
   BUTTON CORE
   ========================= */
.qcb-btn {
    display: inline-flex;
    align-items: center;
    gap: calc(var(--qcb-button-gap) * 0.5);
    padding: calc(var(--qcb-button-gap) * 0.25) calc(var(--qcb-button-gap) * 0.5);
    border-radius: 0.5rem;
    text-decoration: none;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.qcb-btn:active { transform: scale(0.97); }

/* Phone button - direct call or trigger */
.qcb-phone.desktop-only { display: none; }
.qcb-phone.mobile-only { display: inline-flex; }

/* =========================
   ICON SYSTEM
   ========================= */
.qcb-icon-wrapper {
    width: var(--qcb-icon-size);
    height: var(--qcb-icon-size);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--qcb-icon-bg);
    color: var(--qcb-icon-color);
    border-radius: 50%;
    flex-shrink: 0;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.qcb-icon { width: 60%; height: 60%; fill: currentColor; display: block; }

.qcb-icon-no-bg .qcb-icon-wrapper { background: transparent; }
.qcb-icon-square .qcb-icon-wrapper { border-radius: 0.4em; }
.qcb-icon-rounded .qcb-icon-wrapper { border-radius: 0.75em; }

/* =========================
   LABEL SYSTEM
   ========================= */
.qcb-label {
    font-size: calc(var(--qcb-font-size) * 0.9);
    color: var(--qcb-font-color);
    white-space: nowrap;
    text-align: center;
    pointer-events: none;
    font-weight: 600;
    transition: transform 0.25s ease;
}
.qcb-label.always-hide { display: none !important; }
.qcb-label.always-show { display: inline-block !important; }
.qcb-label.mobile-only { display: inline-block; }
.qcb-label.desktop-only { display: none; }

/* =========================
   POPUPS
   ========================= */
.qcb-popups { pointer-events: none; }

.qcb-popup {
    display: none;
    position: fixed;
    bottom: 0;
    left: 50%;
    width: 96vw;
    max-width: 360px;
    background: var(--qcb-popup-bg);
    color: var(--qcb-popup-font-color);
    border-radius: 1rem;
    box-shadow: 0 0.75rem 2rem rgba(0,0,0,0.45);
    opacity: 0;
    transform: translate(-50%, 100%);
    pointer-events: none;
    z-index: 999999;
}

.qcb-popup.qcb-active {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    transition: none; /* disable conflicting transition */
    animation: qcb-popup-show-center 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.qcb-popup-inner {
    padding: 2rem;
    max-height: 90vh;
    overflow-y: auto;
    font-size: 0.95em;
    line-height: 1.35;
}

.qcb-popup-heading {
    margin: 0 0 1.5rem;
    padding-bottom: 0.5rem;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--qcb-popup-heading-color);
    border-bottom: 1px solid currentColor;
}

.qcb-popup-description { margin-bottom: 1rem; }

/* =========================
   POPUP BUTTONS — ALWAYS CENTERED
   ========================= */
.qcb-popup .qcb-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--qcb-button-gap);
    justify-content: center; /* always center */
    align-items: center;
}

.qcb-popup .qcb-btn {
    display: flex;
    flex-direction: row; /* horizontal */
    justify-content: center;
    align-items: center;
    background: transparent;
    box-shadow: none;
    padding: 0.35em 0;
    gap: calc(var(--qcb-button-gap) * 0.25);
}

.qcb-popup .qcb-btn .qcb-icon-wrapper {
    background: var(--qcb-popup-icon-bg);
    color: var(--qcb-popup-icon-color);
    border-radius: 50%;
    transition: transform 0.25s ease;
}

.qcb-popup .qcb-btn .qcb-label {
    background: var(--qcb-popup-label-bg);
    color: var(--qcb-popup-label-color);
    padding: 0.25em 0.5em;
    border-radius: 0.4em;
    text-align: center;
}

/* =========================
   CLOSE BUTTON
   ========================= */
.qcb-popup-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--qcb-popup-font-color);
    opacity: 0.85;
    transition: opacity 0.2s ease, transform 0.12s ease;
}
.qcb-popup-close:hover { opacity: 1; transform: translateY(-1px); }

/* =========================
   SOCIAL MEDIA POPUP
   ========================= */
.qcb-sm-popup-inner { padding: 2rem; }

.qcb-sm-popup-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--qcb-button-gap);
    justify-content: center; /* always center */
    align-items: center;
}

.qcb-sm-popup .qcb-btn {
    flex: 0 0 auto;
    justify-content: center; /* override left-align */
    align-items: center;
    flex-direction: row; /* horizontal */
}

/* =========================
   OVERLAY
   ========================= */
.qcb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
    z-index: 999998;
}
.qcb-overlay.qcb-active {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

.qcb-popup-open { overflow: hidden; }

/* ======================================================
   PHONE POPUP
   ====================================================== */

.qcb-popup .qcb-phone-entry {
    display: flex;
    flex-direction: column; 
    align-items: flex-start;
    justify-content: space-between;
    gap: calc( var(--qcb-button-gap) * 0.25);

    padding:
        calc(var(--qcb-button-gap) * 0.75)
        calc(var(--qcb-button-gap) * 1);

    margin-bottom: calc(var(--qcb-button-gap) * 0.5);

    text-decoration: none;
    color:
        color-mix(
            in srgb,
            var(--qcb-popup-font-color) 85%,
            #000 15%
        );

    background:
        color-mix(
            in srgb,
            var(--qcb-bg) 10%,
            #fff 90%
        );

    border-radius: 0.6rem;

    transition:
        background 0.2s ease,
        transform 0.15s ease;
}

/* Hover / focus */
.qcb-popup .qcb-phone-entry:hover,
.qcb-popup .qcb-phone-entry:focus-visible {
    background:
        color-mix(
            in srgb,
            var(--qcb-bg) 15%,
            #fff 85%
        );
}

/* Active (tap feedback) */
.qcb-popup .qcb-phone-entry:active {
    transform: scale(0.98);
}

.qcb-popup .qcb-phone-dept {
    font-size: calc(var(--qcb-font-size) * 0.85);
    font-weight: 600;
    opacity: 0.85;
    white-space: nowrap;
}

.qcb-popup .qcb-phone-display {
    font-size: calc(var(--qcb-font-size) * 0.95);
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.qcb-popup .qcb-phone-entry:last-child {
    margin-bottom: 0;
}


/* =========================
   DESKTOP ENHANCEMENTS
   ========================= */
@media (min-width: 768px) {

    /* Vertical stack for edges — centered horizontally */
    .qcb.qcb-pos-bottom-right .qcb-buttons .qcb-inner,
    .qcb.qcb-pos-bottom-left  .qcb-buttons .qcb-inner {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        padding: calc(var(--qcb-button-gap) * 0.75)
                 calc(var(--qcb-button-gap) * 0.75);
    }
    
    /* Center stays horizontal */
    .qcb.qcb-pos-bottom-center .qcb-buttons .qcb-inner {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
    }

    /* Retain side-wise icon and label */
    .qcb.qcb-pos-bottom-right .qcb-btn,
    .qcb.qcb-pos-bottom-left  .qcb-btn {
        flex-direction: row;
        text-align: center;
        padding: calc(var(--qcb-button-gap) * 0.35);
    }

    .qcb.qcb-pos-bottom-right .qcb-label,
    .qcb.qcb-pos-bottom-left  .qcb-label {
        font-size: var(--qcb-font-size);
    }

    .qcb-label.desktop-only { display: inline-block; }
    .qcb-label.mobile-only { display: none; }

    /* Phone button - direct call or trigger */
    .qcb-phone.desktop-only { display: inline-flex; }
    .qcb-phone.mobile-only { display: none; }

    .qcb-popup {
        top: 50%;
        bottom: auto;
        max-width: 480px;
        border-radius: 1rem;
        transform: translate(-50%, -50%);
    }
    .qcb-popup.qcb-active {
        transform: translate(-50%, -50%);
        animation: qcb-popup-show-center 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    }
    .qcb.qcb-pos-bottom-center .qcb-popup {
        position: absolute;
        top: auto;
        bottom: calc(100% + 16px);
        left: 50%;
        transform: translateX(-50%);
    }
    .qcb-sm-popup-buttons { justify-content: flex-start; }
    .qcb-popup .qcb-phone-entry { flex-direction: row; gap: var(--qcb-button-gap); }
}

@media (min-width: 1024px) {
    .qcb.qcb-pos-bottom-right .qcb-inner,
    .qcb.qcb-pos-bottom-left  .qcb-inner { align-items: center; }
    .qcb.qcb-pos-bottom-center .qcb-inner { justify-content: center; align-items: center; }
}

/* =========================
   POPUP ANIMATION
   ========================= */
/* Desktop / centered popups */
@keyframes qcb-popup-show-center {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
    60% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}