/* ============================================================
   MOBILE / RESPONSIVE — crmka
   Breakpoint: < 1024px = mobile
   ============================================================ */

/* ── Скрываем доску на мобильных ── */
@media (max-width: 1023.98px) {
    #board-btn-header { display: none !important; }

    /* На мобильных таблица скрыта, карточки показаны */
    #orders-table-container { display: none !important; }
    #card-view-container    { display: block !important; }

    /* Склад: таблица скрыта, карточки показаны */
    .wh-table-wrap          { display: none !important; }
    #wh-footer-bar          { display: none !important; }
    .mob-wh-card-list       { display: block !important; }

    /* Фильтры по дате и переключатель вида — только десктоп */
    .date-filters-container { display: none !important; }
    .view-toggle            { display: none !important; }

    /* Десктопный stat-bar скрыт — замещён мобильными барами */
    .stat-bar               { display: none !important; }

    /* XLS-экспорт скрыт на мобильных */
    #export-orders-xls-btn,
    #export-warehouse-xls-btn { display: none !important; }

    /* Кнопка поддержки — только иконка */
    .hdr-support-btn span   { display: none !important; }
    .hdr-support-btn        {
        width: 34px !important;
        height: 34px !important;
        padding: 0 !important;
        justify-content: center !important;
        border-radius: 50% !important;
    }
    .hdr-support-btn i      { font-size: 1rem !important; }

    /* ── Container ── */
    .container-fluid {
        padding-left: 8px;
        padding-right: 8px;
    }
    body > .container-fluid,
    body .container-fluid:not(.modal .container-fluid) {
        padding-top: 1rem;
    }

    /* ── Card header (панель с заголовком и кнопками) ── */
    .card-header {
        padding: 10px 12px;
    }
    .card-body {
        padding: 8px 12px;
    }
    .ch-title {
        font-size: .875rem;
    }
    .ch-btn {
        font-size: .82rem;
        padding: .38rem .75rem;
    }
}

/* Только десктоп */
@media (min-width: 1024px) {
    #card-view-container  { display: none !important; }
    .mob-wh-card-list     { display: none !important; }
}

/* ============================================================
   МОБИЛЬНЫЕ КАРТОЧКИ ЗАКАЗОВ
   ============================================================ */

.mob-order-card {
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e8eaed;
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
    padding: 1rem;
    margin-bottom: .75rem;
    position: relative;
}

/* Верхняя строка: имя + статус */
.mob-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .5rem;
}

.mob-card-name {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Статус — используем существующие .status-* классы, делаем пилюлей */
.mob-card-top .badge {
    font-size: .7rem !important;
    font-weight: 600 !important;
    padding: .25rem .6rem !important;
    border-radius: 20px !important;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.4;
}

/* Телефон */
.mob-card-phone {
    font-size: .85rem;
    color: #64748b;
    margin-bottom: .45rem;
    font-variant-numeric: tabular-nums;
}
.mob-card-phone:empty { display: none; }

/* Товары */
.mob-card-products {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem .5rem;
    margin-bottom: .55rem;
}

.mob-product-item {
    font-size: .875rem;
    color: #1e293b;
    font-weight: 500;
}

.mob-qty {
    font-size: .78rem;
    color: #94a3b8;
    font-weight: 400;
}

/* Итого */
.mob-card-total {
    font-size: 1.05rem;
    font-weight: 800;
    color: #4f46e5;
    margin-bottom: .5rem;
    letter-spacing: -.01em;
}

/* Мета: менеджер + дата */
.mob-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .75rem;
    color: #94a3b8;
    margin-bottom: .3rem;
    gap: .5rem;
}

.mob-card-manager { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mob-card-date    { white-space: nowrap; flex-shrink: 0; }

/* Комментарий */
.mob-card-comment {
    font-size: .8rem;
    color: #64748b;
    font-style: italic;
    border-left: 2px solid #e2e8f0;
    padding-left: .6rem;
    margin-bottom: .5rem;
    word-break: break-word;
}

/* Разделитель */
.mob-card-divider {
    border: none;
    border-top: 1px solid #f1f5f9;
    margin: .65rem 0 .6rem;
}

/* Кнопки */
.mob-card-actions {
    display: flex;
    gap: .5rem;
}

.mob-btn-edit,
.mob-btn-delete {
    flex: 1;
    padding: .5rem .25rem;
    border-radius: 9px;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    transition: background .13s;
    min-height: 40px;
    -webkit-tap-highlight-color: transparent;
}

.mob-btn-edit {
    border: 1.5px solid #c7d2fe;
    background: #fafafe;
    color: #4f46e5;
}
.mob-btn-edit:hover, .mob-btn-edit:active {
    background: #ede9fe;
}

.mob-btn-delete {
    border: 1.5px solid #fecaca;
    background: #fafafe;
    color: #ef4444;
}
.mob-btn-delete:hover, .mob-btn-delete:active {
    background: #fee2e2;
}

/* Пустое состояние */
.mob-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: #94a3b8;
    font-size: .9rem;
}
.mob-empty i {
    display: block;
    font-size: 2rem;
    margin-bottom: .5rem;
    color: #cbd5e1;
}

/* ============================================================
   МОБИЛЬНЫЕ КАРТОЧКИ СКЛАДА
   ============================================================ */

.mob-wh-card-list {
    padding: 0;
}

.mob-wh-card {
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e8eaed;
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
    padding: .9rem 1rem;
    margin-bottom: .75rem;
}

.mob-wh-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .3rem;
}

.mob-wh-title {
    font-size: .975rem;
    font-weight: 700;
    color: #1e293b;
    flex: 1;
    min-width: 0;
    word-break: break-word;
    line-height: 1.3;
}

.mob-wh-sku {
    font-size: .68rem;
    background: #ede9fe;
    color: #5b21b6;
    padding: .2rem .55rem;
    border-radius: 6px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: .02em;
}

.mob-wh-desc {
    font-size: .82rem;
    color: #64748b;
    margin-bottom: .65rem;
    line-height: 1.4;
}
.mob-wh-desc:empty { display: none; }

/* Нижняя строка: кол-во + цена + кнопки */
.mob-wh-bottom {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}

/* Контрол количества */
.mob-wh-qty-ctrl {
    display: inline-flex;
    align-items: center;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #f8fafc;
}

.mob-wh-qty-btn {
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background .1s;
}
.mob-wh-qty-btn:active { background: #e2e8f0; }

.mob-wh-qty-sep {
    width: 1px;
    height: 20px;
    background: #e2e8f0;
    flex-shrink: 0;
}

.mob-wh-qty-val {
    min-width: 38px;
    text-align: center;
    font-size: .9rem;
    font-weight: 700;
    color: #1e293b;
    padding: 0 4px;
}
.mob-wh-qty-ok   { color: #1e293b; }
.mob-wh-qty-zero { color: #ef4444; }

/* Цена */
.mob-wh-price {
    font-size: .9rem;
    font-weight: 700;
    color: #1e293b;
    margin-left: auto;
    white-space: nowrap;
}
.mob-wh-price-none { color: #94a3b8; font-weight: 400; }

/* Кнопки действий */
.mob-wh-actions {
    display: flex;
    gap: .4rem;
    flex-shrink: 0;
}

.mob-wh-btn {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    -webkit-tap-highlight-color: transparent;
    transition: background .13s;
}

.mob-wh-edit-btn {
    color: #4f46e5;
    border-color: #c7d2fe;
}
.mob-wh-edit-btn:active { background: #ede9fe; }

.mob-wh-del-btn {
    color: #ef4444;
    border-color: #fecaca;
}
.mob-wh-del-btn:active { background: #fee2e2; }

/* ============================================================
   МОБИЛЬНОЕ МОДАЛЬНОЕ ОКНО ЗАКАЗА
   ============================================================ */
@media (max-width: 1023.98px) {
    #orderModal .modal-dialog {
        margin: .5rem;
        max-width: calc(100% - 1rem);
    }
    #orderModal .order-modal-body {
        max-height: 70vh;
        padding: 1rem .85rem;
        gap: .85rem;
    }
    .order-fields-row {
        flex-direction: column;
        gap: .65rem;
    }
    .order-field {
        min-width: unset;
    }
    .order-product-inputs {
        flex-wrap: wrap;
        gap: .5rem;
    }
    .order-product-name-wrap {
        min-width: unset;
        width: 100%;
    }
    .order-field[style*="max-width:120px"],
    .order-field[style*="max-width:90px"] {
        max-width: none !important;
        flex: 1;
    }
    .order-status-pills {
        gap: .3rem;
    }
    .osp-pill {
        font-size: .78rem;
        padding: .3rem .65rem;
    }
    .order-modal-footer {
        padding: .75rem .85rem;
    }
}

/* ============================================================
   МОБИЛЬНОЕ МОДАЛЬНОЕ ОКНО СКЛАДА
   ============================================================ */
@media (max-width: 1023.98px) {
    #warehouseModal .modal-dialog {
        margin: .5rem;
        max-width: calc(100% - 1rem);
    }
}

/* ============================================================
   МОДАЛКА НАСТРОЕК — фиксируем на мобильных
   ============================================================ */
@media (max-width: 1023.98px) {
    .settings-modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
    }
    .settings-modal-content {
        border-radius: 0 !important;
        height: 100% !important;
    }
    .settings-sidebar {
        width: 56px !important;
        min-width: 56px !important;
    }
    .settings-sidebar-header span,
    .settings-nav-item span {
        display: none !important;
    }
    .settings-nav-item {
        justify-content: center !important;
        padding: .6rem 0 !important;
    }
    .settings-sidebar-header {
        justify-content: center !important;
    }
}

/* ============================================================
   МОБ СВОДКА (итого + фильтры-иконки)
   ============================================================ */

/* Скрыть на десктопе */
@media (min-width: 1024px) {
    #mob-summary-bar    { display: none !important; }
    #mob-status-filters { display: none !important; }
}

/* Скрыть мобильные элементы на десктопе */
@media (min-width: 1024px) {
    #mob-date-bar  { display: none !important; }
    #mob-fab-bar   { display: none !important; }
}

/* ── FAB-бар ── */
.mob-fab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 950;
    padding: .65rem .85rem calc(.65rem + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid #e8eaed;
    box-shadow: 0 -4px 16px rgba(0,0,0,.07);
}

.mob-fab-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .85rem 1rem;
    border-radius: 14px;
    border: none;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 52px;
    -webkit-tap-highlight-color: transparent;
    transition: opacity .13s, transform .1s;
}
.mob-fab-btn:active { opacity: .85; transform: scale(.98); }
.mob-fab-btn i { font-size: 1.1rem; }

.mob-fab-primary {
    background: #4f46e5;
    color: #fff;
}
.mob-fab-success {
    background: #059669;
    color: #fff;
}

/* Отступ снизу чтобы FAB не перекрывал контент */
@media (max-width: 1023.98px) {
    body { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important; }
    /* Кнопки добавления скрыты в card-header на мобильных — они в FAB */
    #new-order-btn-header,
    #add-warehouse-item-btn { display: none !important; }
}

/* ── Мобильная полоска дат ── */
.mob-date-bar {
    display: flex;
    align-items: center;
    gap: .35rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding: .45rem .85rem;
    background: #fff;
    border-bottom: 1px solid #e8eaed;
    -webkit-overflow-scrolling: touch;
}
.mob-date-bar::-webkit-scrollbar { display: none; }

.mob-date-pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .75rem;
    border-radius: 20px;
    border: 1.5px solid #e8eaed;
    background: #fff;
    font-family: inherit;
    font-size: .8rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .12s, border-color .12s, color .12s;
    -webkit-tap-highlight-color: transparent;
}
.mob-date-pill.active {
    background: #ebe9ff;
    border-color: #c7d2fe;
    color: #4f46e5;
}
.mob-date-pill:active { transform: scale(.96); }

.mob-date-cal {
    margin-left: auto;
    flex-shrink: 0;
}
.mob-date-cal.has-value {
    background: #ede9fe;
    border-color: #a78bfa;
    color: #5b21b6;
}
#mob-drp-label:empty { display: none; }

/* ── DRP popup как bottom sheet на мобильных ── */
@media (max-width: 1023.98px) {
    #drp-popup {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 18px 18px 0 0 !important;
        box-shadow: 0 -8px 32px rgba(0,0,0,.15) !important;
        z-index: 1100 !important;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    /* Одна колонка — правый календарь скрыт */
    #drp-popup .drp-col-divider,
    #drp-cal-right { display: none !important; }
    #drp-popup .drp-calendars { justify-content: center !important; }
    #drp-cal-left { width: 100% !important; max-width: 340px !important; margin: 0 auto !important; }
    /* Затемнение под попапом */
    #drp-popup.drp-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.35);
        z-index: -1;
    }
}

/* ── Итого ── */
.mob-summary-bar {
    position: sticky;
    top: 56px; /* высота .app-header */
    z-index: 900;
    background: #fff;
    border-bottom: 1px solid #e8eaed;
    padding: .55rem 1rem .5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mob-summary-label {
    font-size: .78rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .05em;
    flex: 1;
}

.mob-summary-amount {
    font-size: 1.1rem;
    font-weight: 800;
    color: #4f46e5;
    letter-spacing: -.02em;
}

/* ── Фильтры-иконки ── */
.mob-status-filters {
    display: flex;
    align-items: center;
    gap: .4rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding: .5rem 1rem;
    background: #fff;
    border-bottom: 1px solid #e8eaed;
    -webkit-overflow-scrolling: touch;
}
.mob-status-filters::-webkit-scrollbar { display: none; }

.mob-sf-pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .65rem;
    border-radius: 20px;
    border: 1.5px solid #e8eaed;
    background: #fff;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    font-size: .8rem;
    font-weight: 600;
    color: #64748b;
    transition: background .13s, border-color .13s, color .13s;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}
.mob-sf-pill i {
    font-size: .85rem;
}
.mob-sf-pill .mob-sf-count {
    font-size: .8rem;
    font-weight: 700;
    min-width: 14px;
    text-align: center;
}
.mob-sf-pill.active {
    background: var(--mob-sf-bg, #ebe9ff);
    border-color: transparent;
    color: var(--mob-sf-color, #4f46e5);
}
.mob-sf-pill:active {
    transform: scale(.96);
}

/* ── Спиннер ленивой пагинации ── */
.mob-load-spinner {
    display: flex;
    justify-content: center;
    gap: .35rem;
    padding: 1.25rem 0;
}
.mob-load-spinner span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #c7d2fe;
    animation: mobBounce .9s ease-in-out infinite;
}
.mob-load-spinner span:nth-child(2) { animation-delay: .15s; }
.mob-load-spinner span:nth-child(3) { animation-delay: .3s; }
@keyframes mobBounce {
    0%, 80%, 100% { transform: scale(.7); opacity: .5; }
    40%           { transform: scale(1);  opacity: 1; }
}

/* ============================================================
   ОЧЕНЬ МАЛЕНЬКИЕ ЭКРАНЫ (< 400px)
   ============================================================ */
@media (max-width: 399px) {
    .mob-card-name   { font-size: .9rem; }
    .mob-wh-title    { font-size: .9rem; }
    .mob-card-total  { font-size: .975rem; }
    .mob-btn-edit,
    .mob-btn-delete  { font-size: .78rem; }
}
