/* ================================================================
   GryadkaDelivery — city chip widget + delivery selection modal
   All classes are prefixed with gd- to avoid Bootstrap 5 conflicts
   ================================================================ */

:root {
    --gd-bg:           #f5f4ef;
    --gd-surface:      #ffffff;
    --gd-ink:          #242424;
    --gd-ink-muted:    #6f7480;
    --gd-olive:        #90af4b;
    --gd-olive-deep:   #556a21;
    --gd-olive-soft:   #eef4df;
    --gd-line:         #dddddd;
    --gd-line-strong:  #d6d5d5;
    --gd-danger:       #cf4444;
    --gd-danger-soft:  #fff0ef;
    --gd-success:      #477927;
    --gd-success-soft: #eef7e6;
    --gd-shadow:       0 24px 60px rgba(58, 67, 34, 0.16);
    --gd-shadow-soft:  0 16px 32px rgba(82, 87, 55, 0.12);
    --gd-radius-lg:    24px;
    --gd-radius-md:    16px;
    --gd-radius-sm:    10px;
}

/* ── City chip (widget in header) ──────────────────────────────── */
.gd-city-chip {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    border: 0;
    min-height: 46px;
    border-radius: 6px;
    padding: 6px 12px 6px 8px;
    background: #ffe2ba;
    color: #111111;
    cursor: pointer;
    text-align: left;
    font: inherit;
}

.gd-city-chip:hover {
    background: #ffd8a0;
}

/* ── Active state: city explicitly chosen ───────────────────────── */
.gd-city-chip--active {
    background: var(--gd-surface);
    border: 1px solid var(--gd-line);
    align-items: flex-start;
}

.gd-city-chip--active:hover {
    background: var(--gd-bg);
}

/* City name + delivery mode on one line */
.gd-city-chip__top {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.gd-city-chip__top small {
    font-weight: 400;
    font-size: 12px;
    line-height: 18px;
    color: var(--gd-ink-muted);
}

/* Address on second line */
.gd-city-chip__address {
    display: block;
    font-size: 12px;
    line-height: 16px;
    color: var(--gd-ink-muted);
    font-weight: 400;
    margin-top: 2px;
}

.gd-city-chip__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 18px;
    flex-shrink: 0;
    color: #D48806;
}

.gd-city-chip__text {
    display: grid;
    gap: 0;
}

.gd-city-chip__text strong {
    font-size: 14px;
    font-weight: 700;
    line-height: 18px;
}

.gd-city-chip__text small {
    font-size: 12px;
    line-height: 16px;
    color: #242424;
}

body:has(#order-simple) .gd-city-chip {
    display: none;
}

/* ── Modal overlay ─────────────────────────────────────────────── */
.gd-modal {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: grid;
    place-items: center;
    padding: 24px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.gd-modal--open {
    visibility: visible;
    opacity: 1;
}

.gd-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

/* ── Modal window ──────────────────────────────────────────────── */
.gd-modal__window {
    position: relative;
    width: min(100%, 1302px);
    height: min(100%, 1007px);
    max-height: min(100%, 1007px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    border-radius: 8px;
    background: var(--gd-surface);
    box-shadow: 0 36px 100px rgba(0, 0, 0, 0.28);
}

/* ── Modal header ──────────────────────────────────────────────── */
.gd-modal__header {
    display: flex;
    align-items: center;
    min-height: 72px;
    padding: 16px 30px;
    border-bottom: 1px solid #dee2e6;
    position: relative;
    background: #fff;
}

.gd-modal__header h1 {
    margin: 0;
    color: #2e3752;
    font-family: "Lobster", cursive;
    font-size: 33px;
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: 0.02px;
}

.gd-modal__close {
    position: absolute;
    top: 50%;
    right: 0;
    width: 80px;
    height: 80px;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gd-ink-muted);
}

.gd-modal__close:hover {
    color: var(--gd-ink);
}

/* ── Modal content (form + map) ────────────────────────────────── */
.gd-modal__content {
    display: grid;
    grid-template-columns: 500px minmax(0, 1fr);
    min-height: 0;
    height: 100%;
}

.gd-modal__form {
    padding: 30px;
    display: grid;
    align-content: start;
    gap: 30px;
    overflow: auto;
    min-height: 0;
    min-width: 0;
    box-sizing: border-box;
}

.gd-modal__map {
    min-width: 0;
    background: #fff;
}

#gd-map {
    width: 100%;
    height: 100%;
    min-height: 300px;
}

/* ── Modal footer ──────────────────────────────────────────────── */
.gd-modal__footer {
    display: flex;
    align-items: center;
    padding: 16px 30px;
    border-top: 1px solid #dee2e6;
    background: #fff;
}

/* ── Field ─────────────────────────────────────────────────────── */
.gd-field {
    display: grid;
    gap: 10px;
    position: relative;
    min-width: 0;
}

.gd-field label,
.gd-field__label {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    color: var(--gd-ink);
}

.gd-label--hidden {
    display: none;
}

/* ── City select button ────────────────────────────────────────── */
.gd-select-btn {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    height: 46px;
    padding: 13px 16px;
    border: 1px solid var(--gd-line-strong);
    border-radius: var(--gd-radius-sm);
    background: #fff;
    width: 100%;
    color: #000;
    cursor: pointer;
    text-align: left;
    appearance: none;
    font: inherit;
    font-size: 16px;
    line-height: 1.25;
    box-sizing: border-box;
}

.gd-select-btn--open {
    border-color: var(--gd-olive);
    border-bottom-color: transparent;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.gd-select-btn__chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    transition: transform 0.16s ease;
    transform-origin: center;
    transform: rotate(180deg);
}

.gd-select-btn--open .gd-select-btn__chevron {
    transform: rotate(0deg);
}

/* ── City dropdown ─────────────────────────────────────────────── */
.gd-dropdown {
    position: absolute;
    top: 46px;
    left: 0;
    right: 0;
    z-index: 5;
    display: grid;
    gap: 0;
    padding: 4px 0;
    border-left: 1px solid var(--gd-olive);
    border-right: 1px solid var(--gd-olive);
    border-bottom: 1px solid var(--gd-olive);
    border-radius: 0 0 10px 10px;
    background: #fff;
    box-shadow: 0 3px 8px rgba(34, 47, 7, 0.2);
    max-height: 220px;
    overflow-y: auto;
}

.gd-dropdown[hidden] {
    display: none !important;
}

.gd-dropdown button {
    border: 0;
    padding: 8px 15px;
    background: #fff;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    line-height: 1.5;
    font: inherit;
    font-size: 13px;
    color: var(--gd-ink);
}

.gd-dropdown button:hover,
.gd-dropdown button.is-selected {
    background: #f3f7eb;
}

.gd-dropdown button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Delivery mode toggle ──────────────────────────────────────── */
.gd-toggle-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.gd-toggle-card {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 10px 11px;
    border: 1px solid var(--gd-line);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    color: var(--gd-ink);
}

.gd-toggle-card--active {
    border-color: var(--gd-olive);
}

.gd-radio-dot {
    position: relative;
    width: 24px;
    height: 24px;
    border: 1px solid #c7c7c7;
    border-radius: 999px;
    flex: 0 0 auto;
}

.gd-toggle-card--active .gd-radio-dot::after {
    content: "";
    position: absolute;
    inset: 2px;
    border-radius: 999px;
    background: var(--gd-olive);
}

/* ── Search / address input ────────────────────────────────────── */
.gd-search-wrap {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    height: 46px;
    padding: 13px 16px;
    border: 1px solid var(--gd-line-strong);
    border-radius: var(--gd-radius-sm);
    background: #fff;
    gap: 8px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.gd-search-wrap:focus-within {
    border-color: var(--gd-olive);
}

.gd-search-wrap input {
    border: 0;
    outline: 0;
    width: 100%;
    min-width: 0;
    font: inherit;
    font-size: 13px;
    background: transparent;
    color: var(--gd-ink);
}

.gd-search-wrap input::placeholder {
    color: var(--gd-ink-muted);
}

#gd-address-clear {
    width: 20px;
    height: 20px;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    color: var(--gd-ink-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
}

#gd-address-clear:hover {
    color: var(--gd-ink);
}

/* ── Status ────────────────────────────────────────────────────── */
.gd-status {
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
}

.gd-status--success {
    background: var(--gd-success-soft);
    color: var(--gd-success);
}

.gd-status--error {
    background: var(--gd-danger-soft);
    color: var(--gd-danger);
}

.gd-status--hidden {
    display: none;
}

/* ── Results list ──────────────────────────────────────────────── */
.gd-list-panel {
    display: grid;
    gap: 14px;
    min-height: 0;
    align-content: start;
}

.gd-list-panel__items {
    display: grid;
    gap: 10px;
    align-content: start;
}

.gd-result-item {
    display: flex;
    align-items: start;
    gap: 8px;
    width: 100%;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--gd-ink);
    cursor: pointer;
    text-align: left;
    font: inherit;
}

.gd-result-item:hover .gd-result-item__text {
    color: var(--gd-olive-deep);
}

.gd-result-item__dot {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    border: 1px solid #c7c7c7;
    border-radius: 999px;
    flex: 0 0 auto;
}

.gd-result-item--selected .gd-result-item__dot {
    border-color: var(--gd-olive);
    box-shadow: inset 0 0 0 2px var(--gd-olive);
}

.gd-result-item__text {
    font-size: 13px;
    line-height: 1.5;
}

.gd-result-empty {
    font-size: 13px;
    color: var(--gd-ink-muted);
    padding: 4px 0;
}

/* ── Show more ─────────────────────────────────────────────────── */
.gd-show-more {
    width: 100%;
    height: 40px;
    border: 0;
    border-radius: 6px;
    background: #f3f7eb;
    color: #2e3752;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
}

.gd-show-more:hover {
    background: var(--gd-olive-soft);
}

/* ── Action (confirm) button ───────────────────────────────────── */
.gd-action-btn {
    min-width: 131px;
    min-height: 46px;
    border: 0;
    border-radius: 10px;
    padding: 12px 30px;
    background: var(--gd-olive);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
}

.gd-action-btn:hover:not(:disabled) {
    background: var(--gd-olive-deep);
}

.gd-action-btn:disabled {
    background: #cfcfcf;
    cursor: not-allowed;
}

/* ── Responsive: stack form + map vertically ───────────────────── */
@media (max-width: 1180px) {
    .gd-modal__content {
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .gd-modal__form {
        flex: 1 1 0;
        min-height: 0;
        overflow-y: auto;
    }

    .gd-modal__map {
        flex: 0 0 auto;
        min-height: 0;
        max-height: 320px;
    }

    #gd-map {
        height: 320px;
        min-height: 0;
    }
}

@media (max-width: 920px) {
    .gd-modal {
        padding: 0;
    }

    .gd-modal__window {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }

    .gd-modal__header {
        align-items: start;
        padding: 16px 20px;
    }

    .gd-modal__header h1 {
        font-size: 28px;
        line-height: 0.95;
        max-width: 290px;
    }

    .gd-modal__form,
    .gd-modal__footer {
        padding-left: 20px;
        padding-right: 20px;
    }

    .gd-modal__map {
        max-height: 280px;
    }

    #gd-map {
        height: 280px;
        min-height: 0;
    }

    .gd-toggle-group {
        gap: 12px;
    }
}

@media (max-width: 640px) {
    .gd-modal__header h1 {
        font-size: 24px;
    }

    .gd-toggle-group {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .gd-toggle-card {
        width: 100%;
        padding-inline: 10px;
    }

    .gd-toggle-card span:last-child {
        font-size: 14px;
    }

    .gd-modal__map {
        max-height: 260px;
    }

    #gd-map {
        height: 260px;
        min-height: 0;
    }

    .gd-modal__footer {
        justify-content: flex-start;
    }

    .gd-action-btn {
        width: 131px;
    }

    .gd-city-chip {
        width: 100%;
    }

    .gd-select-btn,
    .gd-search-wrap {
        width: 100%;
        min-width: 0;
    }
}

/* ── Mobile: hide map, show only form ─────────────────────────── */
@media (max-width: 779px) {
    .gd-modal__map {
        display: none;
    }
}

/* ── Mobile: full-width horizontal strip below header row ──────── */
@media (max-width: 779px) {
    .gd-city-chip {
        display: flex;
        width: 100%;
        box-sizing: border-box;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
        border-top: 1px solid var(--gd-line);
        padding: 10px 12px;
        gap: 10px;
        align-items: center;
    }

    .gd-city-chip--active {
        border-top: 1px solid var(--gd-line);
        align-items: flex-start;
    }
}
