/* ============================================================
   responsive.css – Fixed layout (full-width desktop, clean mobile)
   ============================================================ */

/* Always full width – never center the main column on LCD */
.app,
.main {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}

/* Sidebar backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    padding: 0;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
    visibility: visible;
}

body.sidebar-open {
    overflow: hidden;
}

@media (max-width: 991px) {
    .sidebar-backdrop {
        display: block;
    }
}

/* ── Tablet (≤ 991px) ── */
@media (max-width: 991px) {
    .main {
        padding: 16px;
    }

    .settings-tabs-inner {
        max-width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .settings-tab-item {
        flex-shrink: 0;
    }

    .settings-submenu {
        left: 0;
        top: calc(100% + 4px);
    }

    .patient-toolbar,
    .users-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .patient-toolbar .search-bar form,
    .users-toolbar .search-bar form {
        display: flex;
        width: 100%;
        gap: 8px;
    }

    .patient-toolbar .search-bar input,
    .users-toolbar .search-bar input {
        flex: 1;
        width: auto;
        min-width: 0;
    }

    .patient-form-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .form-grid,
    .patient-form-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .patient-form-grid .span-3 {
        grid-column: 1 / -1;
    }

    .patient-table-wrap,
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Mobile (≤ 767px) ── */
@media (max-width: 767px) {
    .main {
        padding: 12px;
    }

    /* Topbar: title row + actions row */
    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 16px;
    }

    .left-top {
        width: 100%;
        min-width: 0;
    }

    .title-wrap h1 {
        font-size: 1.35rem;
    }

    .title-wrap p {
        font-size: 0.82rem;
    }

    .right-top {
        width: 100%;
        overflow: visible;
    }

    .topbar-actions {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    /* Dashboard search – full width on its own row */
    .topbar-actions > .search {
        flex: 1 1 100%;
        min-width: 0;
        width: 100%;
        height: 42px;
    }

    .profile-name,
    .profile-chevron {
        display: none;
    }

    .topbar-divider {
        display: none;
    }

    /* Page action buttons (e.g. Add Patient) */
    .topbar-actions > a.primary-btn,
    .topbar-actions > .primary-btn {
        flex: 1 1 auto;
        min-width: max-content;
    }

    .form-grid,
    .patient-form-grid,
    .patient-check-grid {
        grid-template-columns: 1fr;
    }

    .patient-form-grid .span-2,
    .patient-form-grid .span-3 {
        grid-column: 1;
    }

    .permission-check-list {
        grid-template-columns: 1fr;
    }

    .patient-form-actions,
    .panel-actions {
        flex-direction: column;
        gap: 8px;
    }

    .patient-form-actions .primary-btn,
    .patient-form-actions .secondary-btn,
    .panel-actions .primary-btn,
    .panel-actions .secondary-btn {
        width: 100%;
        justify-content: center;
    }

    .patient-table-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .patient-footer-left {
        flex-direction: column;
        align-items: flex-start;
    }

    .patient-table-footer .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .toast-root {
        left: 12px;
        right: 12px;
        max-width: none;
        align-items: stretch;
    }

    .toast {
        min-width: 0;
    }
}

/* ── Small mobile (≤ 575px) ── */
@media (max-width: 575px) {
    .main {
        padding: 10px;
    }

    .title-wrap h1 {
        font-size: 1.2rem;
    }

    .menu-toggle {
        width: 36px;
        height: 36px;
    }

    .sidebar {
        width: min(280px, 88vw);
    }

    .patient-record-table {
        min-width: 680px;
    }

    .settings-tab-link {
        font-size: 0.76rem;
        height: 36px;
    }
}

/* ── Login only ── */
@media (max-width: 980px) {
    html.login-page,
    html.login-page body {
        height: auto;
        min-height: 100svh;
        overflow-x: hidden;
        overflow-y: auto;
    }

    html.login-page .page {
        height: auto;
        min-height: 100svh;
        overflow: visible;
        grid-template-columns: 1fr;
    }

    /* Hide left marketing / hero text – form only */
    html.login-page .left-side {
        display: none;
    }

    html.login-page .right-side {
        min-height: 100svh;
        align-items: center;
        justify-content: center;
        padding: 24px 20px;
        border: none;
    }

    html.login-page .form-wrap {
        max-width: 430px;
        width: 100%;
        margin: 0 auto;
    }
}

@media (max-width: 575px) {
    html.login-page .right-side {
        padding: 16px 14px;
    }
}
