/* Mobile responsive overrides for user and admin interfaces */

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

body {
    overflow-x: hidden;
}

.container {
    width: min(var(--container), calc(100% - 24px));
}

.topbar {
    position: sticky;
    top: 0;
}

.topbar-inner {
    gap: 14px;
}

.topnav {
    row-gap: 10px;
}

.topnav a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.search-box input,
input,
select,
textarea,
.btn-primary,
.btn-secondary,
.btn-danger,
.download-btn,
.logout-link {
    min-height: 44px;
}

.table-wrap {
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 1100px) {
    .page-grid,
    .hero-grid,
    .login-layout,
    .quick-grid {
        grid-template-columns: 1fr;
    }

    .sidebar-panel {
        position: static;
        order: 2;
    }

    .content-panel {
        order: 1;
    }
}

@media (max-width: 900px) {
    .topbar-inner {
        align-items: flex-start;
        flex-direction: column;
        min-height: auto;
        padding: 12px 0;
    }

    .topnav {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .topnav a,
    .logout-link {
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .brand {
        width: 100%;
    }

    .page-shell {
        padding: 18px 0 32px;
    }

    .content-panel,
    .card,
    .hero-copy,
    .hero-panel,
    .sidebar-panel,
    .login-card,
    .login-panel,
    .category-card {
        border-radius: 18px;
    }

    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .inline-tools,
    .admin-tree-toolbar,
    .action-row {
        width: 100%;
    }
}

@media (max-width: 780px) {
    .container {
        width: min(var(--container), calc(100% - 16px));
    }

    .hero-copy,
    .hero-panel,
    .card,
    .content-panel,
    .login-card,
    .login-panel,
    .sidebar-panel,
    .category-card,
    .admin-tree-item {
        padding: 16px;
    }

    .hero-copy h1,
    .login-card h1 {
        font-size: 28px;
        line-height: 1.14;
    }

    .section-head h1,
    .section-head h2,
    .category-name,
    .admin-tree-name,
    .category-head h2 {
        font-size: 22px;
        line-height: 1.2;
    }

    .brand-logo {
        width: 46px;
        height: 46px;
    }

    .brand-text strong {
        font-size: 18px;
    }

    .brand-text span {
        font-size: 12px;
    }

    .hero-logo-card {
        min-height: 180px;
    }

    .hero-logo {
        width: min(100%, 180px);
        max-height: 200px;
    }

    .form-row-2,
    .quick-grid {
        grid-template-columns: 1fr;
    }

    .file-card,
    .table-mobile-card,
    .admin-tree-toggle,
    .category-toggle {
        align-items: flex-start;
    }

    .file-card {
        flex-direction: column;
    }

    .file-meta {
        width: 100%;
    }

    .file-actions {
        width: 100%;
    }

    .download-btn,
    .btn-primary,
    .btn-secondary,
    .btn-danger,
    .logout-link {
        width: 100%;
        justify-content: center;
    }

    .inline-tools {
        display: grid;
        grid-template-columns: 1fr;
    }

    .category-title-row,
    .admin-tree-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .category-counts,
    .admin-tree-badges,
    .file-tags {
        width: 100%;
    }

    .category-toggle,
    .admin-tree-toggle {
        gap: 12px;
    }

    .category-chevron,
    .admin-tree-chevron {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .table-wrap {
        border: 0;
        background: transparent;
        overflow: visible;
    }

    .table,
    .table thead,
    .table tbody,
    .table th,
    .table td,
    .table tr {
        display: block;
        width: 100%;
    }

    .table {
        min-width: 0;
    }

    .table tr {
        margin-bottom: 14px;
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 18px;
        padding: 12px;
        box-shadow: var(--shadow-sm);
    }

    .table th {
        display: none;
    }

    .table td {
        border: 0;
        padding: 8px 4px;
    }

    .table td::before {
        content: attr(data-label);
        display: block;
        font-size: 12px;
        font-weight: 700;
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: .05em;
        margin-bottom: 4px;
    }
}

@media (max-width: 560px) {
    .login-shell {
        padding: 12px 0;
    }

    .login-layout {
        width: min(1120px, calc(100% - 16px));
    }

    .login-card,
    .login-panel,
    .hero-copy,
    .hero-panel,
    .content-panel,
    .sidebar-panel,
    .card,
    .category-card,
    .admin-tree-item {
        border-radius: 16px;
        padding: 14px;
    }

    .hero-badge,
    .badge {
        font-size: 11px;
    }

    .search-box input,
    input,
    select,
    textarea {
        padding: 12px 14px;
    }

    .file-icon,
    .category-icon,
    .admin-tree-icon {
        width: 42px;
        height: 42px;
        border-radius: 14px;
    }

    .topnav {
        gap: 10px;
    }
}
