/* styles.css — мобильная версия с учётом Apple HIG и Material Design */

/* Базовые стили */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f7;
    color: #1d1d1f;
    font-size: 16px; /* 16px — минимум для iOS, предотвращает авто-зум при фокусе */
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Контейнер с учётом safe-area (вырез, домашний индикатор) */
.container {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* Заголовки */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    margin-top: 0;
}

h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.25rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.125rem; margin-bottom: 0.5rem; }

p, span, a, li, button {
    font-weight: 400;
}

/* ========== МОБИЛЬНЫЕ КНОПКИ (touch targets 48–56px) ========== */
/* Apple HIG: min 44pt, комфортно 48pt. Material: 48dp. WCAG: 44px */

.btn {
    min-height: 48px;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    min-height: 56px;
    padding: 14px 24px;
    font-size: 1.0625rem;
}

.btn-success {
    min-height: 56px;
    padding: 14px 24px;
}

.btn-sm {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 0.9375rem;
}

/* Ссылки как кнопки в list-group — выбор точки */
.list-group-item-action.point-link {
    min-height: 64px;
    padding: 18px 20px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    border-radius: 12px;
    margin-bottom: 8px;
}

.list-group-item-action.point-link:last-child {
    margin-bottom: 0;
}

.point-item-content .point-title {
    font-size: 1.0625rem;
}

.point-item-content .point-address {
    font-size: 0.9375rem;
    margin-top: 4px;
}

/* Кнопки добавления товаров */
.add-buttons .btn {
    min-height: 52px;
    width: 100%;
    margin-bottom: 12px;
    font-size: 1rem;
}

.add-buttons .btn:last-child {
    margin-bottom: 0;
}

/* Кнопки в item-group (удалить, +, -) */
.item-group .btn {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 14px;
    font-size: 0.9375rem;
}

.input-group .btn {
    min-width: 48px;
    min-height: 48px;
}

/* Select — увеличен для удобного тапа */
.form-control,
select.form-control,
.item-type-select {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 1rem;
    border-radius: 10px;
}

/* Input для количества */
.quantity-input,
input[type="number"],
input[type="text"] {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 1rem;
}

/* ========== Сетка и отступы на мобильных ========== */
@media (max-width: 767.98px) {
    body {
        margin: 0;
        padding: 0;
    }

    .container {
        padding-top: max(16px, env(safe-area-inset-top));
        max-width: 100%;
    }

    .container.mt-4 {
        margin-top: 1rem !important;
    }

    /* Кнопки в ряд — в колонку на мобильных */
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 12px;
    }

    .d-flex.justify-content-between > div {
        width: 100%;
    }

    .d-flex.justify-content-between .btn {
        width: 100%;
        margin-bottom: 8px;
    }

    .d-flex.justify-content-between .btn:last-child {
        margin-bottom: 0;
    }

    /* Форма — полноширинные поля */
    .form-row {
        flex-direction: column;
        margin-left: 0;
        margin-right: 0;
    }

    .form-group {
        width: 100%;
        max-width: 100%;
        margin-bottom: 16px;
    }

    .form-group.col-md-1, .form-group.col-md-2, .form-group.col-md-3,
    .form-group.col-md-4, .form-group.col-md-5, .form-group.col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Блоки товаров */
    .item-group {
        padding: 16px !important;
        margin-bottom: 16px !important;
    }

    /* Кнопки действий — крупные, друг под другом */
    .action-buttons .action-row {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 16px;
    }

    .action-buttons .action-row:last-child {
        margin-bottom: 0;
    }

    .action-buttons .btn {
        width: 100%;
        margin: 0 !important;
    }

    .d-flex .btn {
        width: 100%;
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-bottom: 12px;
    }

    .d-flex .btn:last-child {
        margin-bottom: 0;
    }

    /* Список печатей — крупные тапабельные ссылки */
    .printer-history .list-group-item {
        min-height: 56px;
        padding: 16px 20px;
        font-size: 1rem;
    }

    .printer-history-link {
        display: block;
        padding: 4px 0;
        min-height: 44px;
        line-height: 1.4;
    }
}

/* ========== Планшеты и десктоп ========== */
@media (min-width: 768px) {
    .add-buttons .btn {
        width: auto;
        margin-bottom: 0;
        margin-right: 8px;
    }

    .action-buttons {
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 12px;
    }

    .action-buttons .action-row {
        display: flex;
        flex-direction: row;
        gap: 12px;
        margin-bottom: 0;
    }

    .action-buttons .btn {
        width: auto;
    }
}

/* Кнопка настроек Android — 48px touch target, safe-area */
.android-settings-btn {
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    z-index: 9999;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 50%;
    background: #333;
    color: #fff;
    border: none;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
    line-height: 48px;
    text-align: center;
}

/* Стили для активной кнопки "Комментарий" */
.btn-info.active {
    background-color: #17a2b8;
    border-color: #17a2b8;
    color: #fff;
}

.comment-row {
    margin-top: 12px;
}

.item-group .form-row .btn {
    flex: 0 0 auto;
}

#auth-status {
    color: #666;
    margin-bottom: 12px;
}

/* Главная: кнопка "Начать печать" — крупная на мобильных */
.btn-start-print {
    width: 100%;
    min-height: 56px;
}

@media (min-width: 768px) {
    .btn-start-print {
        width: auto;
    }
}

.btn-change-point {
    flex-shrink: 0;
}

/* Таблица на мобильных — горизонтальный скролл */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767.98px) {
    .table {
        font-size: 0.9375rem;
    }

    .table th, .table td {
        padding: 12px 10px;
    }
}

/* Убираем синюю подсветку при тапе на iOS */
* {
    -webkit-tap-highlight-color: transparent;
}

button, a, input, select, textarea {
    -webkit-tap-highlight-color: transparent;
}
