/* ================================================================
   PayHub PWA — базовый app.css (типографика + утилиты)
   Детальные токены — в tokens.css; layout — в layout.css
   ================================================================ */

html, body {
    /* Шрифт и базовый размер управляются из настроек (appearanceManager в theme.js):
       --app-font-family ставится на :root, а font-size на html задаётся inline в px.
       Базовые 14px — дефолт «Обычный», от него каскадятся rem Bootstrap/DevExpress. */
    font-family: var(--app-font-family, 'Roboto', sans-serif);
    font-size: 14px;
    color: #2A2F5B;
    background-color: #f8f9fa;
    -webkit-font-smoothing: antialiased;
    /* iOS Safari не «раздувает» текст при смене ориентации. */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Убираем горизонтальный скролл от случайного переполнения (off-canvas drawer, широкий
       элемент и т.п.). В Safari-вкладке такой скролл виден, в standalone-PWA — нет.
       Именно `clip`, а не `hidden`: `overflow-x: hidden` на html/body форсит overflow-y:auto
       (вложенный скролл) и ломает sticky-топбар и прокрутку .main-content. `clip` — без побочек. */
    max-width: 100%;
    overflow-x: clip;
}

/* iOS Safari авто-зумит ВСЮ страницу при фокусе на поле с font-size < 16px, после чего
   вёрстка «не вписывается» по горизонтали и зум остаётся. Firefox iOS так не делает —
   потому там всё ок. Фиксируем минимум 16px для полей ввода на тач/узких экранах. */
@media (max-width: 768px) {
    input:not([type=checkbox]):not([type=radio]):not([type=range]),
    select,
    textarea,
    .form-control,
    .form-select,
    .dxbl-text-edit-input {
        font-size: 16px !important;
    }
}

html.app-dark body {
    color: #c9d1d9;
    background-color: #0d1117;
}

h1:focus { outline: none; }

a, .btn-link { color: #1572E8; }
a:hover     { color: #1269DB; }

.btn-primary {
    color: #fff;
    background-color: #177dff;
    border-color: #1269DB;
}

.btn:focus, .btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem rgba(113,106,202,0.4);
}

.content { padding-top: 1.1rem; }

.valid.modified:not([type=checkbox]) { outline: 1px solid #35cd3a; }
.invalid { outline: 1px solid #f3545d; }
.validation-message { color: #f3545d; }

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbmsiPjwvc3ZnPg==) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}
.blazor-error-boundary::after { content: "Произошла ошибка."; }

/* ── Boot screen: логотип PayHub + прогресс-бар с % (вместо стандартного ring) ──
   Используем штатные переменные загрузки Blazor:
   --blazor-load-percentage (напр. 47%) и --blazor-load-percentage-text ("47%").
   Классы loading-progress / loading-progress-text сохранены, чтобы рантайм
   проставлял на них переменные; .boot-bar-fill наследует их через каскад. */
.boot-screen {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 24px;
    background: radial-gradient(120% 120% at 50% 35%, #1b212b 0%, #0f1216 70%);
}
.boot-logo {
    width: 150px; max-width: 52vw; height: auto;
    filter: drop-shadow(0 10px 32px rgba(0,0,0,0.45));
    animation: boot-pulse 1.8s ease-in-out infinite;
}
@keyframes boot-pulse {
    0%, 100% { transform: scale(1);    opacity: 0.9; }
    50%      { transform: scale(1.05); opacity: 1; }
}
.boot-bar {
    position: relative; display: block; margin: 0; inset: auto;
    width: 240px; max-width: 70vw; height: 6px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px; overflow: hidden;
}
.boot-bar-fill {
    display: block; height: 100%;
    width: var(--blazor-load-percentage, 0%);
    background: linear-gradient(90deg, #177dff, #716aca);
    border-radius: 999px;
    box-shadow: 0 0 12px rgba(113, 106, 202, 0.6);
    transition: width 0.2s ease-out;
}
.boot-text {
    position: static; inset: auto; margin: 0;
    font-size: 13px; font-weight: 500; letter-spacing: 0.3px;
    color: rgba(255, 255, 255, 0.78);
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.boot-text:after { content: var(--blazor-load-percentage-text, "Загрузка…"); }

code { color: #716aca; }

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}
.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ── Утилиты ─────────────────────────────────────────────── */
.text-ph-primary   { color: #2A2F5B !important; }
.text-ph-muted     { color: #95aac9 !important; }
.text-ph-accent    { color: #716aca !important; }
.bg-ph-card        { background: #ffffff !important; }

html.app-dark .text-ph-primary { color: #c9d1d9 !important; }
html.app-dark .text-ph-muted   { color: #6e7681 !important; }
html.app-dark .bg-ph-card      { background: #161b22 !important; }

/* ── DX компоненты — базовые цвета ──────────────────────── */
.custom-header { background-color: #ece8f8 !important; }

/* DevExpress Drawer panel nav-menu item цвета */
html.app-dark .dxbl-menu .dxbl-btn,
html.app-dark .dxbl-menu .dxbl-btn span {
    color: #c9d1d9 !important;
}
html.app-dark .dxbl-menu .dxbl-btn:hover {
    background: rgba(255,255,255,0.06) !important;
    color: #e6edf3 !important;
}

/* ── DxPopup / модальные окна (подтверждение и отмена ордера, QR и т.п.) — тёмная тема ──
   Окна DxPopup рендерятся как модалки: структура .dxbl-modal > .dxbl-modal-root >
   .dxbl-popup > .dxbl-modal-content > (.dxbl-modal-header | .dxbl-modal-body | .dxbl-modal-footer).
   Тело .dxbl-modal-body по умолчанию белое (--dxbl-popup-body-bg из темы blazing-berry),
   а текст внутри — светлый из Bootstrap dark → не читается.
   Красим сами элементы напрямую (классы взяты из DevTools) + переопределяем переменные
   попапа на html.app-dark — чтобы тёмными стали и вложенные попапы (список комбобокса). */
html.app-dark {
    --dxbl-popup-bg: #161b22;
    --dxbl-popup-color: #c9d1d9;
    --dxbl-popup-body-bg: #161b22;
    --dxbl-popup-body-color: #c9d1d9;
    --dxbl-popup-border-color: #30363d;
    --dxbl-window-bg: #161b22;
    --dxbl-window-color: #c9d1d9;
    --dxbl-window-border-color: #30363d;
}
/* Контент, тело и футер модалки — тёмный фон, светлый текст */
html.app-dark .dxbl-modal-content,
html.app-dark .dxbl-modal-body,
html.app-dark .dxbl-modal-footer,
html.app-dark .dxbl-popup,
html.app-dark .dxbl-window-dialog,
html.app-dark .dxbl-window-body,
html.app-dark .dxbl-window-footer {
    background-color: #161b22 !important;
    color: #c9d1d9 !important;
    border-color: #30363d !important;
}
/* Шапка — чуть темнее */
html.app-dark .dxbl-modal-header,
html.app-dark .dxbl-window-header {
    background-color: #0d1117 !important;
    color: #e6edf3 !important;
    border-bottom-color: #30363d !important;
}
/* Заголовки/текст внутри окна */
html.app-dark .dxbl-modal-content h1, html.app-dark .dxbl-modal-content h2,
html.app-dark .dxbl-modal-content h3, html.app-dark .dxbl-modal-content h4,
html.app-dark .dxbl-modal-content h5, html.app-dark .dxbl-modal-content h6,
html.app-dark .dxbl-modal-content p,  html.app-dark .dxbl-modal-content span,
html.app-dark .dxbl-modal-content label,
html.app-dark .dxbl-modal-content .text-body {
    color: #c9d1d9 !important;
}
/* Поля ввода внутри окна (комбобокс «причина отмены» и его выпадающий список) */
html.app-dark .dxbl-modal-content .dxbl-text-edit,
html.app-dark .dxbl-modal-content input[type="text"],
html.app-dark .dxbl-modal-content input[type="search"],
html.app-dark .dxbl-popup .dxbl-text-edit,
html.app-dark .dxbl-popup input[type="text"],
html.app-dark .dxbl-popup input[type="search"] {
    background-color: #0d1117 !important;
    border-color: #30363d !important;
    color: #c9d1d9 !important;
}
html.app-dark .dxbl-modal-content input::placeholder,
html.app-dark .dxbl-popup input::placeholder { color: #6e7681 !important; }

/* ── Адаптив модальных окон DxPopup под мобильные ──
   У DxPopup ширина задаётся инлайном (Width="720px" и т.п.) и на узком экране
   окно вылезает за края. Глобально (scoped CSS до .dxbl-popup не дотягивается)
   ужимаем окно под вьюпорт и даём телу прокручиваться по вертикали. */
@media (max-width: 720px) {
    .dxbl-popup {
        width: calc(100vw - 16px) !important;
        max-width: calc(100vw - 16px) !important;
        min-width: 0 !important;
    }
    .dxbl-modal-content,
    .dxbl-window-dialog {
        max-height: calc(100vh - 24px);
    }
    .dxbl-modal-body,
    .dxbl-window-body {
        overflow-y: auto;
    }
    /* Футер с кнопками — растягиваем кнопки, чтобы их было удобно нажимать. */
    .dxbl-modal-footer,
    .dxbl-window-footer {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* ── Жёлтая плашка ввода суммы продажи (OutorderChekUpload, порт из монолита) ──
   Глобально (без scoped): input — это дочерний компонент InputNumber, scoped CSS
   до него не дотягивается. Классы специфичны (sell-amount-*), коллизий нет. */
.sell-amount-plaque {
    background: #f8f9fa;
    padding: 0.75rem;
    border-radius: 8px;
    border-left: 4px solid #c8a900;   /* акцентный жёлтый */
}
.sell-amount-label {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 0.4rem;
}
.sell-amount-input {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}
.sell-amount-input.is-valid-soft {
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.18);
}
.sell-amount-input.is-invalid-soft {
    border-color: #dc3545;
}
.sell-amount-hint {
    font-size: 0.78rem;
    margin-top: 0.3rem;
    color: #dc3545;
}
/* Тёмная тема плашки */
html.app-dark .sell-amount-plaque {
    background: rgba(255, 215, 0, 0.06);
    border-left-color: #c8a900;
}
html.app-dark .sell-amount-label { color: #e6edf3; }
html.app-dark .sell-amount-input {
    background-color: #0d1117;
    border-color: #30363d;
    color: #c9d1d9;
}
html.app-dark .sell-amount-input.is-valid-soft { border-color: #28a745; }
html.app-dark .sell-amount-input.is-invalid-soft { border-color: #dc3545; }

/* ── Кнопки Да/Отмена в попапе подтверждения ордера ──
   Шире, скруглённые (pill), разнесены друг от друга. */
.confirm-footer-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2.5rem;            /* подальше друг от друга */
    width: 100%;
    padding: 0.25rem 0;
}
.confirm-footer-actions .confirm-action-btn,
.confirm-action-btn {
    min-width: 150px;                  /* визуально шире */
    border-radius: 999px !important;   /* скруглённые */
    font-weight: 600 !important;
}
