/* dialog.css — модальные окна и собственный alert.

   Классы .alert_window / .alert_buttons / .alert_button раньше жили в двух
   файлах сразу (style-mainpage.css и basket.css) с разными размерами и
   отступами. Страница, которая не подключала ни один из них, получала окно
   без стилей: /availability-requests/ показывала оформление заказа простым
   блоком внизу страницы, потому что display:none был описан не здесь.
   Теперь описание одно и подключено в base.html — окно выглядит одинаково
   на любой странице, а правила вроде .rs-order-modal.active остаются
   поверх, так как их файлы подключаются позже. */

.alert_window_overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: var(--z-backdrop);
    backdrop-filter: blur(4px);
}

.alert_window_overlay.active {
    display: block;
    animation: nd-dialog-fade .2s var(--ease, ease);
}

.alert_window {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(420px, calc(100vw - 32px));
    box-sizing: border-box;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--gray-medium);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-modal);
}

.alert_window.active {
    display: block;
    animation: nd-dialog-rise .25s var(--ease, ease);
}

.alert_window h2 {
    margin: 0 0 16px;
    color: var(--text-color);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.35;
}

/* ===== Выбор размеров внутри окна ===== */

.sizes_labels {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

/* Сама галочка не нужна: отмеченный размер видно по подсветке плашки.
   Клик по плашке — это клик по label, разметка остаётся прежней. */
.select_size_block input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.select_size_block label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    min-height: 44px;
    padding: 0 12px;
    border: 1.5px solid var(--gray-medium);
    border-radius: var(--radius-medium);
    background: var(--surface);
    color: var(--text-color);
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.select_size_block input[type="checkbox"]:checked + label {
    border-color: var(--primary-color);
    background: var(--primary-light);
    color: var(--primary-color);
}

.select_size_block input[type="checkbox"]:focus-visible + label {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.select_size_block input[type="checkbox"]:disabled + label {
    opacity: .45;
    cursor: not-allowed;
}

@media (hover: hover) {
    .select_size_block input[type="checkbox"]:not(:disabled) + label:hover {
        border-color: var(--primary-color);
    }
}

/* ===== Кнопки окна ===== */

.alert_buttons {
    display: flex;
    gap: 10px;
}

.alert_button {
    flex: 1;
    min-height: 44px;
    padding: 0 16px;
    border: none;
    border-radius: var(--radius-medium);
    font-family: inherit;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.alert_button:first-child {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-on-brand);
}

.alert_button:first-child:disabled {
    background: var(--gray-medium);
    color: var(--text-light);
    cursor: not-allowed;
}

.alert_button:last-child {
    background: var(--gray-light);
    color: var(--text-color);
}

.alert_button:only-child {
    flex: none;
    margin-left: auto;
    min-width: 140px;
}

@media (hover: hover) {
    .alert_button:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: var(--shadow-sm);
    }
}

/* ===== Собственный alert вместо браузерного ===== */

.nd-alert-text {
    margin: 0 0 20px;
    color: var(--text-color);
    font-size: .98rem;
    line-height: 1.5;
    white-space: pre-line;      /* \n в сообщениях остаются переносами */
    overflow-wrap: anywhere;
}

.nd-alert-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-bottom: 14px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary-color);
    font-size: 1.1rem;
}

.nd-alert--danger .nd-alert-icon {
    background: var(--danger-bg);
    color: var(--danger-text);
}

@keyframes nd-dialog-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes nd-dialog-rise {
    from { opacity: 0; transform: translate(-50%, -44%) scale(.97); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@media (max-width: 480px) {
    .alert_window {
        padding: 20px 18px;
    }

    .alert_buttons {
        flex-direction: column-reverse;
    }

    .alert_button:only-child {
        margin-left: 0;
        width: 100%;
    }
}
