/*
 * The app shell: a fixed top bar, the menu on the left (a slide-in panel below 992 px), the page and its footer.
 * Markup: Views/Shared/_Layout, _topbar, _sidebar and _footer; behaviour: js/layout.js.
 */
:root {
    --topbar-height: 64px;
    --sidebar-width: 250px;
}

/* ============================================
   TOP BAR
   ============================================ */
.app-topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    height: var(--topbar-height);
    background-color: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
}

/* As wide as the menu below it, so the logo and the menu share one column. */
.app-brand-box {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: .25rem;
    width: var(--sidebar-width);
    height: 100%;
    padding: 0 1rem 0 1.25rem;
    border-right: 1px solid var(--app-border);
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    min-width: 0;
    color: var(--ink);
    font-size: 1.0625rem;
    font-weight: 600;
    white-space: nowrap;
}

.app-brand:hover {
    color: var(--app-primary);
}

.app-brand img {
    width: 34px;
    height: 34px;
}

.app-topbar-actions {
    display: flex;
    align-items: center;
    gap: .25rem;
    margin-left: auto;
    padding: 0 1rem;
}

.topbar-button {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    height: 40px;
    padding: 0 .7rem;
    border: 0;
    border-radius: .5rem;
    background: transparent;
    color: var(--app-text);
    font-size: .875rem;
    font-weight: 500;
    white-space: nowrap;
}

.topbar-button:hover,
.topbar-button:focus-visible,
.topbar-button.show {
    background-color: var(--app-hover);
    color: var(--ink);
}

.topbar-button:focus-visible {
    outline: 2px solid var(--app-primary-light);
    outline-offset: 1px;
}

.topbar-button .topbar-caret {
    font-size: 1.1rem;
    color: var(--muted);
}

.user-menu .user-icon {
    font-size: 1.6rem;
    color: var(--app-primary);
}

/* The bell: what waits for the user (friend requests, new recommendations) as a count on it. */
.topbar-bell {
    position: relative;
    justify-content: center;
    width: 40px;
    padding: 0;
    font-size: 1.35rem;
    text-decoration: none;
}

.topbar-bell-count {
    position: absolute;
    top: 4px;
    right: 2px;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 .3rem;
    border-radius: 999px;
    background-color: var(--app-danger);
    color: #fff;
    font-size: .7rem;
    font-weight: 600;
    line-height: 1.1rem;
    text-align: center;
}

.language-menu img,
.dropdown-item.language img {
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .08);
}

.dropdown-item.language {
    display: flex;
    align-items: center;
}

.user-menu-email {
    display: block;
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-toggle {
    display: none;
    flex: 0 0 auto;
    justify-content: center;
    width: 40px;
    padding: 0;
    font-size: 1.5rem;
}

/* ============================================
   MENU
   ============================================ */
.app-sidebar {
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    z-index: 1020;
    width: var(--sidebar-width);
    padding: .5rem 0 1.5rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    background-color: var(--app-surface);
    border-right: 1px solid var(--app-border);
    scrollbar-width: thin;
    scrollbar-color: #CDD4DD transparent;
}

.app-menu {
    margin: 0;
    padding: 0;
    list-style: none;
}

.app-menu-heading {
    padding: 1rem 1.5rem .35rem;
    font-size: .8125rem;
    font-weight: 600;
    color: #8A93A3;
}

.app-menu-heading:first-child {
    padding-top: .5rem;
}

.app-menu a {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1px .75rem;
    padding: .5rem .75rem;
    border-radius: .5rem;
    color: var(--app-text);
    font-size: .875rem;
    font-weight: 500;
    line-height: 1.35;
}

.app-menu a > i {
    flex: 0 0 auto;
    font-size: 1.2rem;
    color: #7B8494;
}

.app-menu a > .badge {
    margin-left: auto;
}

.app-menu a:hover {
    background-color: var(--app-hover);
    color: var(--ink);
}

.app-menu a:hover > i {
    color: var(--app-primary);
}

.app-menu a:focus-visible {
    outline: 2px solid var(--app-primary-light);
    outline-offset: -2px;
}

.app-menu a.active {
    background-color: var(--app-primary-subtle);
    color: var(--app-primary);
    font-weight: 600;
}

.app-menu a.active > i {
    color: var(--app-primary);
}

/* ============================================
   PAGE AND FOOTER
   ============================================ */
.app-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    padding-top: var(--topbar-height);
}

.app-content {
    flex: 1 0 auto;
    padding: 1.25rem .75rem .25rem;
}

/* Legal links on the left, the TMDB logo and source line on the right; two lines on phones. */
.app-footer {
    flex-shrink: 0;
    padding: 10px 1.5rem;
    font-size: var(--type-meta);
    color: var(--muted);
    border-top: 1px solid var(--app-border);
}

.footer-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0 16px;
    min-height: 40px;
    line-height: 20px;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 12px;
}

.footer-links a,
.tmdb-attribution a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: rgba(0, 0, 0, .25);
}

.footer-links a:hover,
.tmdb-attribution a:hover {
    color: var(--ink);
}

.tmdb-attribution {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .75rem;
}

.tmdb-logo img {
    display: block;
    width: auto;
    height: 12px;
}

/* ============================================
   PHONES AND TABLETS
   ============================================ */
@media (max-width: 991.98px) {
    .app-brand-box {
        width: auto;
        padding-left: .5rem;
        border-right: 0;
    }

    .menu-toggle {
        display: inline-flex;
    }

    /* Hidden, not only moved away: its links stay out of the keyboard order while it is closed. */
    .app-sidebar {
        visibility: hidden;
        transform: translateX(-100%);
        transition: transform .25s ease, visibility .25s;
    }

    .menu-open .app-sidebar {
        visibility: visible;
        transform: none;
        box-shadow: .5rem 0 2rem rgba(18, 38, 63, .18);
    }

    .menu-open::before {
        content: "";
        position: fixed;
        inset: var(--topbar-height) 0 0 0;
        z-index: 1015;
        background-color: rgba(18, 28, 45, .45);
    }

    .menu-open {
        overflow: hidden;
    }

    .app-main {
        margin-left: 0;
    }

    .app-content {
        padding: 1rem .25rem .25rem;
    }

    .app-footer {
        padding-right: 1rem;
        padding-left: 1rem;
    }

    /* Dialogs fill the screen: the header and the footer stay put and only the body scrolls, so the actions stay
       within reach. Small confirmations (.modal-sm) keep their size. */
    .modal-dialog:not(.modal-sm) {
        width: 100%;
        max-width: 100%;
        height: 100%;
        margin: 0;
    }

    .modal-dialog:not(.modal-sm) .modal-content {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        max-height: 100vh;
        border: 0;
        border-radius: 0;
    }

    .modal-dialog:not(.modal-sm) .modal-body {
        flex: 1 1 auto;
        overflow-y: auto;
    }

    .modal-dialog:not(.modal-sm) .modal-header,
    .modal-dialog:not(.modal-sm) .modal-footer {
        flex: 0 0 auto;
    }
}

@media (max-width: 359.98px) {
    .app-brand span {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .card-header,
    .btn-toolbar {
        flex-wrap: wrap;
        gap: .4rem;
    }
}

/* Touch screens: larger targets. */
@media (pointer: coarse) {
    .btn {
        min-height: 40px;
    }

    .btn-sm {
        min-height: 34px;
    }

    .form-control,
    .form-select,
    .dx-texteditor-input {
        min-height: 40px;
    }

    .dx-datagrid .dx-data-row > td {
        padding-top: 9px;
        padding-bottom: 9px;
    }

    .nav-link,
    .dropdown-item {
        padding-top: .6rem;
        padding-bottom: .6rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-sidebar {
        transition: none;
    }
}

@media print {
    .app-topbar,
    .app-sidebar,
    .app-footer {
        display: none;
    }

    .app-main {
        margin: 0;
        padding: 0;
    }
}
