/* Геометрия приложения. Карта и правила: docs/wiki/frontend.md */
:root {
    --sidebar-width: 200px;
    --header-height: 45px;
    --nav-height: 0px;
    --app-height: 100vh;
    --viewport-top: 0px;
    --account-health-height: 0px;
}
@supports (height: 100dvh) { :root { --app-height: 100dvh; } }
body { height: auto; min-height: 100vh; }
main {
    margin: calc(var(--header-height) + var(--account-health-height)) 0 0 var(--sidebar-width);
    min-width: 0;
    min-height: calc(var(--app-height) - var(--header-height) - var(--account-health-height));
}
#mainContent { min-width: 0; width: 100%; }
.sidebar { height: calc(var(--app-height) - var(--header-height)); overflow-y: auto; }
.top-header { width: 100%; }
.account-health-banner { position: fixed; top: calc(var(--viewport-top) + var(--header-height) + var(--nav-height)); left: var(--sidebar-width); right: 0; z-index: 1050; max-height: calc(var(--app-height) * .25); overflow-y: auto; box-sizing: border-box; }
.top-header .logo-section { min-width: 0; flex-shrink: 1; }
.avito-sync-status { position: relative; min-width: 0; }
.avito-sync-status summary { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avito-sync-panel { position: absolute; top: calc(100% + 8px); left: 0; width: 350px; max-width: calc(100vw - 24px); max-height: calc(var(--app-height) - var(--header-height) - 24px); overflow-y: auto; overflow-wrap: anywhere; z-index: 1100; }
@media (max-width: 640px) {
    .avito-sync-label { display: none; }
    .avito-sync-compact { display: inline-block; text-align: left; }
    .avito-sync-compact-value { display: block; font-size: 11px; }
    .avito-sync-status summary { min-height: 40px; display: flex; align-items: center; padding: 0 3px; }
    .avito-sync-panel { position: fixed; top: calc(var(--header-height) + 6px); left: 8px; right: 8px; width: auto; max-width: none; }
}
input, textarea, select { color: var(--text-primary); }
:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.user-menu:focus-within .user-dropdown { display: block; }
.app-modal {
    top: var(--viewport-top) !important;
    bottom: auto !important;
    height: var(--app-height);
    padding: 12px;
    overflow-y: auto;
}
.app-modal > div {
    min-width: 0;
    max-height: calc(var(--app-height) - 24px) !important;
    overflow-y: auto;
    overflow-wrap: anywhere;
}
.app-modal input, .app-modal select, .app-modal textarea { min-width: 0; max-width: 100%; }
.avito-connector-panel { width: 92%; max-width: 560px; padding: 24px; text-align: left; }
.avito-connector-actions { display: flex; flex-wrap: wrap; gap: 10px; }

@media (max-width: 1000px) {
    :root { --sidebar-width: 0px; --nav-height: 48px; }
    .top-header { padding: 0 6px; gap: 4px; }
    .logo-section { padding: 0; }
    .top-header .logo { font-size: 14px; color: var(--primary-color); }
    .top-header .search-bar { min-width: 0; margin: 0; padding: 0; }
    .header-actions { gap: 2px; padding: 0; }
    #currentUserEmail, .notification-btn { display: none; }
    .theme-toggle, .top-header .user-avatar { min-width: 36px; min-height: 36px; }
    .sidebar {
        top: var(--header-height);
        width: 100%; height: var(--nav-height);
        overflow: hidden;
    }
    .sidebar-header, .sidebar-footer, .nav-title { display: none; }
    .sidebar-nav { display: flex; overflow-x: auto; overflow-y: hidden; padding: 0; }
    .nav-section { display: flex; flex: 0 0 auto; margin: 0; padding: 0; }
    .sidebar .nav-item { flex: 0 0 auto; padding: 8px 12px; min-height: 44px; gap: 6px; }
    .sidebar .nav-text { display: inline; opacity: 1; font-size: 13px; white-space: nowrap; }
    .sidebar .nav-icon { margin: 0; }
    main { margin-left: 0; margin-top: calc(var(--header-height) + var(--nav-height) + var(--account-health-height)); min-height: 0; }
    input:not([type="checkbox"]):not([type="radio"]), textarea, select { font-size: 16px !important; }
    .account-info { width: 100%; }
    .account-controls, .account-actions { flex-wrap: wrap; }
    .account-controls button, .filter-btn, .add-account-btn { min-height: 44px; }
    .app-modal > div { padding: 16px !important; width: 100% !important; }
    .app-modal button { min-height: 44px; }
}
@media (max-width: 1000px) {
    #soundToggle { display: block; min-width: 36px; min-height: 36px; }
    .search-results { position: fixed; top: var(--header-height); left: 6px; right: 6px; }
    .search-filters { flex-wrap: wrap; }
}

/* Initial HTML while the selected section loads; no demonstration data. */
.app-startup { max-width: 420px; margin: 40px auto; padding: 24px; text-align: center; color: var(--text-primary); }
.app-startup h2 { font-size: 20px; margin-bottom: 10px; }
.app-startup p, .app-startup noscript { color: var(--text-secondary); font-size: 14px; line-height: 1.5; }

/* Unread count remains visible when a different section is open. */
.dialogs-menu-unread {
    margin-left: auto;
    min-width: 18px;
    padding: 1px 5px;
    border-radius: 10px;
    background: var(--danger-color);
    color: white;
    font-size: 11px;
    text-align: center;
    flex-shrink: 0;
}
.dialogs-menu-unread[hidden], .notification-badge[hidden] { display: none; }


/* MAX QR connection shares the account modal overlay. */
.max-login-card {
    background: var(--card-bg); color: var(--text-primary); padding: 24px;
    border-radius: 16px; width: min(520px, 92vw); max-height: 88dvh;
    overflow-y: auto; box-sizing: border-box;
}
.max-login-card p { color: var(--text-secondary); margin: 12px 0; }
#maxQrCode { display: flex; justify-content: center; margin: 18px 0; }
#maxQrCode img, #maxQrCode canvas { background: white; padding: 12px; }
#maxLoginStatus { margin: 12px 0; }
.max-login-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.max-login-card button { min-height: 44px; padding: 10px 16px; cursor: pointer; }
.max-login-card form label { display: block; margin: 10px 0; }
.max-login-card input { font-size: 16px; padding: 10px; box-sizing: border-box; max-width: 100%; }
