/* ============================================================================
   MOBILE-FIRST АДАПТИВНЫЕ СТИЛИ
   Mimino Restaurant Management System
   ============================================================================

   Этот файл содержит адаптивные стили для ВСЕХ страниц.
   Загружается после style.css и переопределяет стили для мобильных устройств.

   Основные breakpoints:
   - max-width: 992px  - планшеты и меньше
   - max-width: 768px  - мобильные устройства
   - max-width: 576px  - маленькие телефоны

   Ключевые улучшения:
   - Touch-friendly кнопки (минимум 44x44px, на мобильных 48x48px)
   - Адаптивные таблицы (превращаются в карточки на мобильных)
   - Hamburger меню с правильным позиционированием dropdown
   - Увеличенные размеры шрифтов для лучшей читаемости
   - Предотвращение zoom на iOS (font-size: 16px минимум)

   ВАЖНО: Не содержит специфичных для меню стилей (.product-card в menu.css)
   ============================================================================ */

/* === БАЗОВЫЕ НАСТРОЙКИ === */
* {
    -webkit-tap-highlight-color: rgba(88, 166, 255, 0.2);
    -webkit-touch-callout: none;
}

html {
    /* Предотвращает zoom при фокусе на input на iOS */
    -webkit-text-size-adjust: 100%;
}

body {
    /* Убираем горизонтальную прокрутку */
    overflow-x: hidden;
    min-height: 100vh;
}

/* === КОНТЕЙНЕРЫ === */
.container, .container-fluid {
    padding-left: 15px;
    padding-right: 15px;
}

@media (max-width: 576px) {
    .container, .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* === НАВИГАЦИЯ === */
.navbar {
    padding: 0.5rem 1rem;
}

@media (max-width: 992px) {
    .navbar-collapse {
        background: var(--ds-surface);
        padding: 1rem;
        border-radius: var(--ds-radius-sm);
        margin-top: 10px;
        border: 1px solid var(--ds-border);
    }

    .navbar-nav {
        gap: 0.5rem;
    }

    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        border-radius: var(--ds-radius-xs);
        background: rgba(88, 166, 255, 0.08);
        margin-bottom: 0.5rem;
        font-size: 16px;
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    /* Dropdown меню внутри hamburger - статическое позиционирование */
    .navbar-nav .dropdown-menu {
        position: static !important;
        float: none;
        width: 100%;
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
        background: var(--ds-surface);
        border: 1px solid var(--ds-border);
        border-radius: var(--ds-radius-xs);
        transform: none !important;
    }

    .navbar-nav .dropdown-item {
        padding: 0.75rem 1rem;
        font-size: 15px;
        min-height: 48px;
        display: flex;
        align-items: center;
        white-space: normal;
    }

    .navbar-nav .dropdown-item i {
        min-width: 24px;
        margin-right: 8px;
    }
}

/* Hamburger menu - улучшенная видимость */
.navbar-toggler {
    border: 1px solid var(--ds-border);
    padding: 0.5rem 0.75rem;
    background: rgba(88, 166, 255, 0.1);
    border-radius: var(--ds-radius-xs);
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
    outline: none;
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2888, 166, 255, 1%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='3' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    width: 24px;
    height: 24px;
}

/* === КНОПКИ - TOUCH-FRIENDLY === */
.btn {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 8px;
    touch-action: manipulation;
    user-select: none;
}

@media (max-width: 768px) {
    .btn {
        padding: 12px 24px;
        font-size: 18px;
        min-height: 48px;
    }

    .btn-sm {
        min-height: 40px;
        padding: 8px 16px;
        font-size: 14px;
    }

    .btn-lg {
        min-height: 56px;
        padding: 14px 28px;
        font-size: 20px;
    }
}

/* Кнопки в ряд на мобильных */
@media (max-width: 576px) {
    .btn-group-mobile {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .btn-group-mobile .btn {
        width: 100%;
    }
}

/* === ТАБЛИЦЫ - АДАПТИВНЫЕ === */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 992px) {
    .table {
        font-size: 14px;
    }

    .table td, .table th {
        padding: 0.5rem;
        white-space: nowrap;
    }
}

@media (max-width: 576px) {
    .table {
        font-size: 12px;
    }

    .table td, .table th {
        padding: 0.3rem;
    }
}

/* Карточный вид для таблиц на мобильных */
@media (max-width: 768px) {
    .table-mobile-cards {
        display: block;
    }

    .table-mobile-cards thead {
        display: none;
    }

    .table-mobile-cards tbody,
    .table-mobile-cards tr {
        display: block;
        width: 100%;
    }

    .table-mobile-cards tr {
        margin-bottom: 1rem;
        border: 1px solid var(--ds-border);
        border-radius: var(--ds-radius-sm);
        padding: 1rem;
        background: var(--ds-surface);
    }

    .table-mobile-cards td {
        display: block;
        text-align: right;
        padding: 0.5rem 0;
        border: none;
        position: relative;
        padding-left: 50%;
    }

    .table-mobile-cards td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
        color: var(--ds-accent);
    }
}

/* === ФОРМЫ === */
.form-control {
    font-size: 16px; /* Предотвращает zoom на iOS */
    min-height: 44px;
    padding: 10px 15px;
}

@media (max-width: 768px) {
    .form-control {
        font-size: 18px;
        min-height: 48px;
        padding: 12px 18px;
    }

    .form-label {
        font-size: 16px;
        margin-bottom: 8px;
    }
}

/* Форма в колонку на мобильных */
@media (max-width: 576px) {
    .form-row,
    .row.g-3 {
        flex-direction: column;
    }

    .form-row > *,
    .row.g-3 > * {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* === КАРТОЧКИ ПРОДУКТОВ === */
/* Стили .product-card и .product-grid определены в menu.css (специфичны для меню) */

/* === МОДАЛЬНЫЕ ОКНА === */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-content {
        border-radius: 15px;
    }

    .modal-header,
    .modal-footer {
        padding: 1rem;
    }

    .modal-body {
        padding: 1.5rem 1rem;
    }
}

/* === DATATABLES АДАПТАЦИЯ === */
@media (max-width: 768px) {
    .dataTables_wrapper .dataTables_filter input {
        width: 100%;
        margin-left: 0;
        margin-top: 0.5rem;
    }

    .dataTables_wrapper .dataTables_length select {
        width: 100%;
    }

    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: center;
        float: none !important;
        margin-top: 1rem;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.5rem 0.75rem;
        margin: 0.1rem;
    }
}

/* === СПИСКИ === */
@media (max-width: 576px) {
    ul, ol {
        padding-left: 1.5rem;
    }

    li {
        margin-bottom: 0.75rem;
    }
}

/* === ЗАГОЛОВКИ === */
h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.35rem;
    }

    h3 {
        font-size: 1.15rem;
    }
}

@media (max-width: 576px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.1rem;
    }
}

/* === ПАНЕЛИ ДЕЙСТВИЙ === */
.bulk-actions-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .bulk-actions-panel {
        flex-direction: column;
    }

    .bulk-actions-panel .btn {
        width: 100%;
        text-align: center;
    }
}

/* === ЧЕКБОКСЫ - УВЕЛИЧЕННЫЕ ДЛЯ TOUCH === */
input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

@media (max-width: 768px) {
    input[type="checkbox"] {
        width: 24px;
        height: 24px;
    }
}

/* === АЛЕРТЫ === */
.alert {
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 576px) {
    .alert {
        font-size: 14px;
        padding: 0.75rem;
    }
}

/* === КАРТЫ (CARD) === */
.card {
    border-radius: 12px;
    margin-bottom: 1rem;
}

@media (max-width: 576px) {
    .card {
        border-radius: 8px;
    }

    .card-body {
        padding: 1rem;
    }
}

/* === GRID СИСТЕМЫ === */
@media (max-width: 768px) {
    .row {
        margin-left: -10px;
        margin-right: -10px;
    }

    .row > * {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* === ФИКСИРОВАННЫЕ ЭЛЕМЕНТЫ === */
@media (max-width: 768px) {
    .fixed-bottom,
    .fixed-top {
        position: sticky;
    }
}

/* === УТИЛИТЫ === */
.mobile-only {
    display: none !important;
}

.desktop-only {
    display: block !important;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-hidden {
        display: none !important;
    }
}

/* === ТЕНИ И ЭФФЕКТЫ === */
@media (max-width: 768px) {
    .shadow,
    .shadow-sm,
    .shadow-lg {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    }
}

/* === SPACING UTILITIES === */
@media (max-width: 576px) {
    .p-5 { padding: 1.5rem !important; }
    .p-4 { padding: 1rem !important; }
    .m-5 { margin: 1.5rem !important; }
    .m-4 { margin: 1rem !important; }
}

/* === LANDSCAPE MODE === */
@media (max-width: 992px) and (orientation: landscape) {
    body {
        font-size: 14px;
    }

    .navbar {
        padding: 0.25rem 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .modal-dialog {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* === ACCESSIBILITY === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* === ТЕМНАЯ ТЕМА НА УСТРОЙСТВАХ === */
@media (prefers-color-scheme: dark) {
    body {
        background-color: var(--ds-bg);
    }

    .card,
    .modal-content {
        background-color: var(--ds-surface);
    }
}

/* === ПЕЧАТЬ === */
@media print {
    .navbar,
    .btn,
    .bulk-actions-panel,
    input[type="checkbox"] {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .table {
        border: 1px solid black;
    }
}
