/* ============================================================
   МОБИЛЬНАЯ ВЕРСИЯ (ширина ≤ 768px)
   ============================================================ */

@media (max-width: 768px) {

    /* === БАЗОВОЕ === */
    body {
        padding: 0;
        background: white;
    }

    .container {
        padding: 8px 4px;
        border-radius: 0;
        box-shadow: none;
        background: white;
        max-width: 100%;
        margin: 0;
        overflow-x: hidden;
    }


    /* === СЕЛЕКТОРЫ МЕСЯЦА/ГОДА === */
    .controls {
        gap: 6px;
        flex-wrap: nowrap;
        justify-content: center;
    }

    .control-group {
        flex-shrink: 0;
    }

    .controls label {
        font-size: 11px;
    }

    .controls select {
        padding: 4px 6px;
        font-size: 11px;
        min-width: 50px;
        max-width: 90px;
        height: 28px;
    }


    /* === ТАБЛИЦЫ: СКРЫТЬ ДЕСКТОП, ПОКАЗАТЬ МОБИЛЬНУЮ === */
    .table-wrapper {
        display: none;
    }

    .mobile-table-wrapper {
        display: block;
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: 70vh;
        max-width: 100%;
    }


    /* === МОБИЛЬНАЯ ТАБЛИЦА === */
    .mobile-table {
        width: 100%;
        min-width: 0;
        table-layout: fixed;
        border-collapse: collapse;
        font-size: 11px;
    }

    .mobile-table thead {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .mobile-table th {
        padding: 4px 1px;
        text-align: center;
        font-weight: 600;
        font-size: 9px;
        border: 1px solid #5f4dd0;
        white-space: normal;
        word-wrap: break-word;
        line-height: 1.2;
        background: #6c5ce7;
        color: white;
        position: sticky;
        top: 0;
        z-index: 11;
    }

    .mobile-table th:first-child {
        background: #6c5ce7;
        color: white;
        position: sticky;
        left: 0;
        top: 0;
        z-index: 12;
        width: 36px;
        min-width: 36px;
        max-width: 36px;
        font-size: 9px;
        padding: 4px 1px;
        line-height: 1.2;
    }

    .mobile-table td {
        padding: 2px;
        text-align: center;
        border: 1px solid #dfe6e9;
        cursor: pointer;
        height: 36px;
        vertical-align: middle;
        background: white;
    }

    .mobile-table td:first-child {
        background: #f8f9fa;
        font-weight: 600;
        color: #2d3436;
        position: sticky;
        left: 0;
        z-index: 5;
        font-size: 10px;
        width: 36px;
        min-width: 36px;
        max-width: 36px;
        padding: 4px 2px;
        cursor: default;
        border-right: 2px solid #dfe6e9;
    }

    .mobile-table td:first-child .day-number-mobile {
        display: block;
        font-size: 10px;
        font-weight: 700;
        white-space: nowrap;
    }

    .mobile-table td:first-child .day-weekday-mobile {
        display: block;
        font-size: 7px;
        font-weight: 400;
        color: #636e72;
    }

    .mobile-table td:first-child.weekend-mobile {
        background: #fff3cd;
    }

    .mobile-table td:first-child.weekend-mobile .day-number-mobile {
        color: #e17055;
    }

    .mobile-table td:not(:first-child):hover {
        background: #e8f0fe;
    }


    /* === ЦВЕТНЫЕ ЯЧЕЙКИ === */
    .mobile-table td .cell-content {
        display: block;
        width: 80%;
        height: 80%;
        margin: 10% auto;
        border-radius: 4px;
        font-size: 11px;
        font-weight: 700;
        line-height: 1;
        min-height: 18px;
    }

    .mobile-table td .cell-content.slots-mine {
        background: #00b894;
        color: white;
    }

    .mobile-table td .cell-content.slots-free {
        background: #fdcb6e;
        color: #2d3436;
    }

    .mobile-table td .cell-content.slots-zero {
        background: #dfe6e9;
        color: #b2bec3;
    }


    /* === ВЫДЕЛЕНИЕ ЯЧЕЙКИ === */
    .mobile-table td.selected .cell-content {
        background: #6c5ce7 !important;
        color: white !important;
    }


    /* === ИНФОРМАЦИЯ О ВЫБОРЕ === */
    .selection-info {
        margin-top: 15px;
        padding: 12px;
    }


    /* === КНОПКИ БРОНИРОВАНИЯ === */
    .booking-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .btn {
        padding: 10px 8px;
        font-size: 13px;
        min-height: 44px;
    }

    .btn--ghost {
        flex-basis: 100%;
        font-size: 12px;
        min-height: 36px;
    }


    /* === ШАПКА И ФУТЕР === */
    .topbar {
        padding: 4px 8px;
        margin-bottom: 4px;
    }

    .topbar__link {
        font-size: 12px;
        padding: 2px 6px;
    }

    .topbar__user {
        gap: 6px;
        font-size: 12px;
    }

    .topbar__login,
    .topbar__logout-btn {
        font-size: 12px;
    }

    .flash {
        padding: 6px 10px;
        margin: 4px 0;
        font-size: 12px;
    }

    .footer {
        padding: 8px;
        font-size: 11px;
        margin-top: 10px;
    }


    /* === ЛЕГЕНДА === */
    .legend {
        gap: 8px;
        padding: 6px 8px;
        margin-top: 6px;
        font-size: 11px;
    }

    .legend__swatch {
        width: 14px;
        height: 14px;
    }


    /* === ПОДСКАЗКА === */
    .hint {
        margin-top: 6px;
    }

    .hint__summary {
        padding: 6px 10px;
        font-size: 12px;
    }

    .hint__body {
        padding: 0 10px 8px 10px;
        font-size: 11px;
    }

    kbd {
        font-size: 10px;
        padding: 0 3px;
    }


    /* === СЕЛЕКТ ВОДИТЕЛЯ (АДМИН) === */
    .admin-driver-select {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding: 6px 10px;
        font-size: 12px;
        margin: 4px 0;
    }

    .admin-driver-select label {
        font-size: 11px;
    }

    .admin-driver-select select {
        width: 100%;
        max-width: 100%;
        font-size: 12px;
        padding: 5px 8px;
    }


    /* === ФИО ВОДИТЕЛЯ === */
    .driver-header {
        margin-bottom: 8px;
    }

    .driver-header__fio {
        font-size: 15px;
    }

    .driver-header__un {
        font-size: 12px;
    }
}


/* ============================================================
   ОЧЕНЬ МАЛЕНЬКИЕ ЭКРАНЫ (≤ 480px)
   ============================================================ */

@media (max-width: 480px) {

    .container {
        padding: 8px;
    }

    .mobile-table {
        font-size: 10px;
    }

    .mobile-table th {
        padding: 3px 1px;
        font-size: 8px;
    }

    .mobile-table th:first-child {
        width: 32px;
        min-width: 32px;
        max-width: 32px;
        font-size: 8px;
        padding: 3px 1px;
    }

    .mobile-table td {
        padding: 1px;
        height: 32px;
    }

    .mobile-table td:first-child {
        width: 32px;
        min-width: 32px;
        max-width: 32px;
        font-size: 9px;
        padding: 3px 1px;
    }

    .mobile-table td:first-child .day-number-mobile {
        font-size: 9px;
    }

    .mobile-table td:first-child .day-weekday-mobile {
        font-size: 6px;
    }

    .mobile-table td .cell-content {
        font-size: 10px;
        min-height: 16px;
    }

    .topbar {
        padding: 2px 6px;
        margin-bottom: 2px;
    }

    .topbar__link,
    .topbar__user,
    .topbar__login,
    .topbar__logout-btn {
        font-size: 11px;
    }

    .footer {
        padding: 6px;
        font-size: 10px;
        margin-top: 8px;
    }

    .legend {
        gap: 6px;
        padding: 4px 6px;
        font-size: 10px;
    }

    .legend__swatch {
        width: 12px;
        height: 12px;
    }

    .admin-driver-select {
        padding: 4px 8px;
        font-size: 11px;
    }

    .admin-driver-select select {
        font-size: 11px;
        padding: 4px 6px;
    }

    .driver-header__fio {
        font-size: 14px;
    }
}
