/* Portrait mobile / PWA — load last */

.toast-host {
    position: fixed;
    left: max(1rem, env(safe-area-inset-left, 0));
    right: max(1rem, env(safe-area-inset-right, 0));
    bottom: calc(1rem + env(safe-area-inset-bottom, 0));
    z-index: 9999;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    background: #1a2a4a;
    color: #fff;
    font-size: 0.95rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    transform: translateY(120%);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    pointer-events: none;
    max-width: 28rem;
    margin: 0 auto;
}

.toast-host--visible {
    transform: translateY(0);
    opacity: 1;
}

.toast-host--warning {
    background: #5d4037;
}

.toast-host--error {
    background: #b71c1c;
}

.book-slot-form .btn.is-loading {
    opacity: 0.65;
    pointer-events: none;
}

body.guard-scan-page .container {
    padding-bottom: 2rem;
}

.guard-scan-page {
    max-width: 480px;
    margin: 0 auto;
}

.guard-scan-hint--small {
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
}

.guard-qr-reader {
    width: 100%;
    min-height: min(55vw, 280px);
    margin: 0 auto 0.75rem;
    border-radius: 16px;
    overflow: hidden;
    background: #0d1b33;
}

.guard-qr-reader video {
    border-radius: 16px;
    object-fit: cover;
}

.guard-camera-status {
    text-align: center;
    font-weight: 600;
    margin: 0.5rem 0 0.75rem;
    color: var(--vy-blue, #0039A6);
}

.guard-camera-btn {
    min-height: 48px;
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
}

.guard-manual-block {
    margin-top: 1.25rem;
    padding: 0.75rem 0;
}

.guard-manual-block summary {
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

#qr-reader__scan_region {
    min-height: 240px;
}

#qr-reader__dashboard {
    display: none !important;
}

.guard-pass-modal-box {
    max-width: 420px;
    max-height: 92vh;
    overflow-y: auto;
}

.guard-modal-title {
    margin: 0 0 0.5rem;
    padding-left: 12px;
    border-left: 4px solid var(--campus-cta, #0039A6);
}

.guard-modal-title--ok {
    color: #1a7f37;
    border-left-color: #1a7f37;
}

.guard-modal-title--error {
    color: #b42318;
    border-left-color: #b42318;
}

.guard-modal-badge {
    font-weight: 700;
    color: #1a7f37;
    margin: 0 0 1rem;
}

.guard-modal-fio {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
}

.guard-modal-photo-wrap {
    text-align: center;
    margin-bottom: 1rem;
}

.guard-modal-photo {
    width: 100%;
    max-width: 280px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.guard-modal-card {
    margin-bottom: 1rem;
    padding: 1rem;
}

.guard-modal-valid {
    margin-top: 0.75rem;
}

.guard-modal-error {
    margin: 1rem 0;
    color: #b42318;
}

.guard-result {
    margin-top: 1.25rem;
    padding: 1rem;
    border-radius: 12px;
}

.guard-result--ok {
    background: #e8f5e9;
    border: 2px solid #28a745;
}

.guard-result--error {
    background: #ffebee;
    border: 2px solid #c62828;
}

.guard-result-fio {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.guard-result-photo {
    max-width: 200px;
    border-radius: 8px;
    margin-top: 0.75rem;
}

/* Portrait mobile / PWA */

html {
    -webkit-text-size-adjust: 100%;
}

body {
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

footer {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0));
}

.container {
    padding-left: max(0.85rem, env(safe-area-inset-left, 0));
    padding-right: max(0.85rem, env(safe-area-inset-right, 0));
}

body.layout-wide .container,
body.layout-wide.admin-dashboard-page .admin-panel-page {
    padding-left: max(0.85rem, env(safe-area-inset-left, 0));
    padding-right: max(0.85rem, env(safe-area-inset-right, 0));
}

/* Touch-friendly forms (iOS: 16px prevents zoom on focus) */
input,
select,
textarea,
.btn,
button[type="submit"],
.nav-toggle,
.map-filter,
.map-locate-btn,
.faq-question {
    touch-action: manipulation;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
}

.table-scroll table {
    min-width: 520px;
}

@media (max-width: 480px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
    select,
    textarea,
    .btn,
    button[type="submit"] {
        min-height: 44px;
        font-size: 16px;
    }

    .container--auth {
        max-width: none;
        width: 100%;
        padding-left: max(0.75rem, env(safe-area-inset-left, 0));
        padding-right: max(0.75rem, env(safe-area-inset-right, 0));
    }

    .auth-form {
        padding: 1.25rem 1rem;
    }

    /* Bento / home */
    .bento-welcome h1,
    .heading-brand {
        font-size: 1.35rem;
        line-height: 1.25;
    }

    .bento-icon {
        font-size: 1.75rem;
    }

    .home-news-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .news-item--compact {
        grid-template-columns: 1fr;
    }

    .news-item--compact .news-image,
    .news-image {
        max-height: 180px;
        width: 100%;
        object-fit: cover;
    }

    /* Schedule page header */
    .schedule-header {
        padding: 1rem;
    }

    .schedule-header h1,
    .schedule-header h2 {
        font-size: 1.35rem;
    }

    .schedule-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .schedule-filters .btn,
    .schedule-filters select,
    .schedule-filters input {
        width: 100%;
    }

    /* Map */
    .map-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .map-filters {
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .map-filter,
    .map-locate-btn {
        flex: 1 1 auto;
        min-height: 44px;
    }

    #vyatsuMap,
    .yandex-map-frame,
    .map-canvas-wrap--widget iframe {
        height: min(50dvh, 360px) !important;
        min-height: 240px;
    }

    .map-list-row {
        min-height: 48px;
        padding: 0.75rem 0.85rem;
    }

    .map-layout {
        gap: 1rem;
    }

    /* Appointment / teacher */
    .date-picker {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        padding-bottom: 0.25rem;
        margin-left: -0.25rem;
        margin-right: -0.25rem;
        padding-left: 0.25rem;
    }

    .date-pill {
        flex: 0 0 auto;
        scroll-snap-align: start;
        min-width: 96px;
    }

    .appointment-teachers,
    .teacher-slots-layout {
        grid-template-columns: 1fr !important;
    }

    .teacher-dashboard-page .teacher-slots-sidebar {
        max-height: none;
    }

    .student-cabinet-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .student-cabinet-qr {
        display: flex;
        justify-content: center;
    }

    .student-cabinet-qr img {
        max-width: min(220px, 80vw);
    }

    .teacher-profile-actions {
        flex-direction: column;
    }

    .teacher-profile-actions .btn {
        width: 100%;
        text-align: center;
    }

    /* Admin */
    .admin-students-toolbar {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .admin-students-toolbar .form-group,
    .admin-students-toolbar .btn {
        width: 100%;
    }

    .admin-pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .admin-panel-page details form input,
    .admin-panel-page details form select {
        width: 100%;
        box-sizing: border-box;
    }

    /* Nav user dropdown */
    .nav-user-dropdown {
        left: 0;
        right: auto;
        min-width: min(280px, calc(100vw - 2rem));
    }

    .page-header h1 {
        font-size: 1.35rem;
    }
}

@media (max-width: 768px) {
    .nav-user-dropdown {
        left: 0;
        right: auto;
    }
}
