/* ==========================================================================
   Bottom Bar — Sticky store finder
   ========================================================================== */

/* Varataan sivun pohjalle tilaa barin verran, ettei footerin alaosa jää piiloon.
   JS (footer.php) päivittää --dg-bottom-bar-height arvon barin todelliseen
   korkeuteen. !important tarvitaan, koska WP injectoi inline-styleilla
   body { padding-bottom: 0 } joka muuten voittaa spesifisyydellä. */
body {
    padding-bottom: var(--dg-bottom-bar-height, 0px) !important;
}

.dg-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    background-color: var(--wp--preset--color--ice-blue);
    box-shadow: 0 -4px 20px rgba(0, 16, 32, 0.12);
    transition: transform 0.3s ease;
}

.dg-bottom-bar > .dg-bottom-bar__close {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
}

.dg-bottom-bar--hidden {
    transform: translateY(100%);
    pointer-events: none;
}

.dg-bottom-bar__inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 0;
    margin: 0 auto;
}

/* States */
.dg-bottom-bar__state {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 0;
}

/* Search form */
.dg-bottom-bar__search-form {
    flex: 1;
    min-width: 0;
}

.dg-bottom-bar__input-wrapper {
    display: flex;
    align-items: center;
    background-color: transparent;
    border: 2px solid var(--wp--preset--color--black);
    border-radius: 4px;
}

.dg-bottom-bar__input {
    flex: 1;
    border: none;
    background: transparent !important;
    border: 0 !important;
    padding: 0.65rem 1rem;
    font-size: 0.875rem;
    color: var(--wp--preset--color--black);
    outline: none;
    min-width: 0;
}

.dg-bottom-bar__input::placeholder {
    color: var(--wp--preset--color--text-gray);
}

.dg-bottom-bar__locate-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border: none;
    border-left: 1px solid var(--wp--preset--color--border-gray);
    background: transparent;
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--wp--preset--color--dark-blue);
    cursor: pointer;
    white-space: nowrap;
}

.dg-bottom-bar__locate-btn:hover {
    color: var(--wp--preset--color--primary-dark);
}

.dg-bottom-bar__locate-icon {
    width: 18px;
    height: 18px;
    opacity: 0.6;
}

/* Actions (WP buttons) */
.dg-bottom-bar__actions {
    flex-shrink: 0;
    gap: 0.5rem !important;
}

.dg-bottom-bar__actions .wp-block-button__link {
    padding: 0.5rem 1.2rem !important;
    font-size: 0.85rem !important;
    white-space: nowrap;
}

/* Store found state */
.dg-bottom-bar__store-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--wp--preset--color--dark-blue);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Close button */
.dg-bottom-bar__close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0;
}

.dg-bottom-bar__close:hover {
    color: var(--wp--preset--color--dark-blue);
}

/* ==========================================================================
   Search results flyout (dg-yext plugin generates .dg-bottom-bar__results)
   ========================================================================== */

.dg-bottom-bar__input-wrapper {
    position: relative;
}

.dg-bottom-bar__results {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--wp--preset--color--border-gray, #ddd);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
    max-height: 280px;
    overflow-y: auto;
    z-index: 1050;
}

.dg-bottom-bar__result-item {
    padding: 0.65rem 1rem;
    font-size: 0.875rem;
    color: var(--wp--preset--color--dark-blue);
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.dg-bottom-bar__result-item:last-child {
    border-bottom: none;
}

.dg-bottom-bar__result-item:hover {
    background-color: var(--wp--preset--color--ice-blue, #f0f6ff);
}

.dg-bottom-bar__results-header,
.dg-bottom-bar__results-message {
    padding: 0.5rem 1rem 0.4rem;
    font-size: 0.8rem;
    color: var(--wp--preset--color--text-gray, #707070);
    font-style: italic;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* Mobile */
@media (max-width: 991px) {
    .dg-bottom-bar__inner {
        flex-direction: column;
        padding: 0.6rem 1rem;
    }

    .dg-bottom-bar__state {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .dg-bottom-bar__search-form {
        width: 100%;
    }

    .dg-bottom-bar__actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .dg-bottom-bar__store-name {
        flex: 1 1 100%;
        margin-bottom: 0.25rem;
    }

    .dg-bottom-bar > .dg-bottom-bar__close {
        top: 0.6rem;
        right: 0.6rem;
        transform: none;
        z-index: 1;
    }

    /* Bottom bar pysyy fixedinä myös mobiilissa */

    /* Relative positioning for close button */
    .dg-bottom-bar__inner {
        position: relative;
        padding-right: 2.5rem;
    }
}
