/* css/mobile.css - Mobile Responsiveness */

/* Default: hide mobile-only UI controls */
.mobile-only {
    display: none !important;
}

#sidebar-overlay {
    position: fixed;
    top: calc(var(--app-topbar-height, 52px) + var(--safe-top, 0px));
    left: 0;
    width: 100%;
    height: calc(var(--app-vh, 100vh) - var(--app-topbar-height, 52px) - var(--safe-top, 0px));
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    display: none;
    backdrop-filter: blur(2px);
}

@media (max-width: 900px) {
    .mobile-only {
        display: inline-flex !important;
    }

    .app-topbar {
        min-height: calc(var(--app-topbar-height, 52px) + var(--safe-top, 0px));
        max-height: calc(var(--app-topbar-height, 52px) + var(--safe-top, 0px));
        height: calc(var(--app-topbar-height, 52px) + var(--safe-top, 0px));
        padding-top: var(--safe-top, 0px);
        padding-left: 8px;
        padding-right: 8px;
    }

    .app-topbar-left,
    .app-topbar-right {
        gap: 6px;
    }

    .topbar-nav-btn {
        width: 34px;
        height: 34px;
        display: inline-flex !important;
        flex: 0 0 auto;
    }

    .app-topbar-logo-wrap {
        padding: 0 2px 0 0;
    }

    .app-topbar-logo {
        height: 24px;
    }

    .topbar-action-btn span:not(.icon) {
        display: none;
    }

    .topbar-action-btn {
        width: 34px;
        justify-content: center;
        padding: 0;
    }

    #topbar-discover-wrap,
    #topbar-bands-wrap {
        display: none !important;
    }

    .topbar-overflow-wrap {
        display: inline-flex !important;
    }

    .topbar-menu-wrap {
        position: static;
    }

    .topbar-menu {
        position: fixed;
        top: calc(var(--app-topbar-height, 52px) + var(--safe-top, 0px) + 6px);
        left: 8px;
        right: 8px;
        min-width: 0;
        max-width: none;
    }

    .container {
        position: relative;
        overflow: hidden;
        height: calc(var(--app-vh, 100vh) - var(--app-topbar-height, 52px) - var(--safe-top, 0px));
        min-height: 0;
    }

    .sidebar {
        position: fixed;
        top: calc(var(--app-topbar-height, 52px) + var(--safe-top, 0px));
        left: 0;
        bottom: 0;
        width: min(88vw, 300px);
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 2px 0 18px rgba(0, 0, 0, 0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-top {
        padding-top: 10px;
        padding-bottom: calc(clamp(4px, 0.8vh, 8px) + var(--browser-bottom-inset, 0px));
    }

    .sidebar-bottom {
        padding-top: 0;
        padding-bottom: 0;
    }

    .list-pane {
        width: 100% !important;
        flex: none;
        min-width: 0;
        display: flex;
    }

    .reading-pane {
        position: fixed;
        top: calc(var(--app-topbar-height, 52px) + var(--safe-top, 0px));
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: calc(var(--app-vh, 100vh) - var(--app-topbar-height, 52px) - var(--safe-top, 0px));
        background: var(--bg-dark);
        z-index: 180;
        transform: translateX(100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .reading-pane.active {
        transform: translateX(0);
    }

    body.mobile-layout-active.mobile-sidebar-open #sidebar-overlay {
        display: block;
    }

    #pane-resizer {
        display: none;
    }

    #sidebar-resizer,
    #sidebar-hover-rail,
    #btn-sidebar-pin,
    #btn-wide-view {
        display: none !important;
    }

    #toolbar {
        padding: 6px 8px;
        gap: 4px;
    }

    #view-controls.mobile-toolbar-scroll {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        gap: 6px;
        padding-bottom: 2px;
    }

    #view-controls.mobile-toolbar-scroll::-webkit-scrollbar {
        height: 4px;
    }

    #view-controls.mobile-toolbar-scroll::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 999px;
    }

    .toolbar-group {
        flex: 0 0 auto;
        padding: 3px 5px;
        gap: 4px;
        border-radius: 10px;
    }

    .toolbar-separator {
        flex: 0 0 auto;
        height: 18px;
    }

    .toolbar-spacer {
        display: none;
    }

    .tool-btn {
        height: 30px;
        padding: 0 8px;
        font-size: 12px;
    }

    .tool-btn.tool-icon {
        min-width: 30px;
    }

    #btn-toggle-player {
        display: none !important;
    }

    .song-header {
        padding: 8px 10px 6px;
    }

    .song-title-row {
        align-items: flex-start;
        margin-bottom: 4px;
    }

    .song-header h1.ti {
        font-size: 1.9rem;
        margin-bottom: 0;
        line-height: 1.07;
        display: flex;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 8px;
    }

    .song-header h1.ti > span {
        flex: 1 1 auto;
        min-width: 0;
    }

    .song-header-actions {
        gap: 6px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .song-meta-link-btn,
    .song-meta-theory-btn,
    .song-meta-versions-btn,
    .mini-meta-btn {
        font-size: 11px;
        padding: 2px 7px;
        min-height: 28px;
    }

    .song-versions-shell {
        right: 0;
        left: auto;
        width: min(560px, calc(100vw - 16px));
        max-width: calc(100vw - 16px);
        min-width: 0;
    }

    .song-versions-pane {
        grid-template-columns: 1fr;
        min-width: 0;
        max-height: min(70vh, 560px);
    }

    .song-versions-list-pane {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        max-height: min(30vh, 260px);
        display: flex;
        flex-direction: column;
    }

    .song-versions-list {
        max-height: min(20vh, 180px);
    }

    .song-versions-actions {
        padding-top: 6px;
    }

    .song-versions-apply-btn {
        min-height: 40px;
        font-size: 14px;
    }

    .song-versions-status {
        font-size: 11px;
    }

    .song-versions-preview-pane {
        max-height: min(34vh, 300px);
    }

    .compact-meta-row {
        gap: 8px;
        font-size: 12px;
        margin-top: 4px;
    }

    .compact-meta-item-extra {
        display: none;
    }

    .tablature-meta {
        margin-top: 6px;
        font-size: 11px;
    }

    #songDisplay {
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    #song-body-scroll-container {
        flex: none !important;
        min-height: 0;
        overflow: visible !important;
        max-height: none !important;
        padding: 0 0 calc(10px + var(--safe-bottom, 0px)) 0;
    }

    #song-body-content {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    #song-body-content.segmented-view .song-part {
        border-left: 0;
        border-right: 0;
        border-radius: 0;
        padding: 10px 10px;
    }

    #song-body-content.two-column {
        column-count: 1 !important;
        column-gap: 0 !important;
        column-rule: none !important;
    }

    .song-part {
        margin-bottom: 8px;
    }

    .segment-label {
        font-size: 10px;
        margin-bottom: 5px;
    }

    .mobile-song-chrome-toggle {
        width: 28px;
        min-width: 28px;
        height: 28px;
        flex: 0 0 auto;
        margin-left: 8px;
        border: 1px solid var(--border);
        border-radius: 8px;
        background: transparent;
        color: var(--text);
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        line-height: 1;
        cursor: pointer;
    }

    .mobile-song-chrome-toggle.active {
        background: var(--bg-hover);
    }

    body.mobile-layout-active.mobile-song-view-active:not(.mobile-song-chrome-open) #toolbar {
        display: none !important;
    }

    body.mobile-layout-active.mobile-song-view-active:not(.mobile-song-chrome-open) .song-header .mobile-song-extra {
        display: none !important;
    }

    body.mobile-layout-active.mobile-song-view-active:not(.mobile-song-chrome-open) .song-header #btn-mobile-song-chrome {
        display: inline-flex !important;
    }

    .chord-line {
        line-height: 1.25;
    }

    .lyric-line {
        line-height: 1.45;
    }

    .mobile-detail-back {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 30px;
        padding: 0 9px;
        border-radius: 8px;
        border: 1px solid var(--border);
        background: transparent;
        color: var(--text);
        cursor: pointer;
    }

    .finder-search-wrap {
        padding: 8px;
        gap: 8px;
    }

    .public-lists-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .public-list-details-header {
        padding: 10px;
        gap: 10px;
    }

    .public-list-details-title {
        font-size: 1.2rem;
    }

    .public-list-details-actions,
    .public-list-details-subactions {
        flex-wrap: wrap;
        gap: 8px;
    }

    .band-finder-detail {
        padding: 12px;
    }

    .band-finder-detail-header {
        gap: 8px;
        margin-bottom: 12px;
    }

    .profile-shell,
    .admin-shell,
    .band-shell {
        grid-template-columns: 1fr;
    }

    .profile-nav,
    .admin-nav,
    .band-nav {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        max-height: 34vh;
        overflow-y: auto;
    }

    .profile-main,
    .admin-main,
    .band-main {
        min-height: 0;
    }

    .band-main {
        padding: 12px;
    }

    .band-nav {
        padding: 12px;
    }

    .band-nav-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .band-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .band-public-header {
        grid-template-columns: 1fr;
    }

    .band-public-headline {
        order: 1;
    }

    .band-public-header-actions {
        order: 2;
    }

    .band-public-tabs {
        overflow-x: auto;
        white-space: nowrap;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }

    .band-people-grid {
        grid-template-columns: 1fr;
    }

    .band-person-card {
        grid-template-columns: 38px 1fr auto;
    }

    .band-member-row {
        grid-template-columns: 1fr;
    }

    .band-member-main {
        grid-template-columns: 38px 1fr;
    }

    .band-member-row-default .band-member-main {
        grid-template-columns: 1fr;
    }

    .thread-view-container {
        min-height: 0;
    }

    .thread-header {
        padding: 10px 12px;
    }

    .messages-scroll-area {
        padding: 10px;
    }

    .message-bubble {
        max-width: 92%;
    }

    .reply-area {
        padding: 10px;
        gap: 8px;
    }

    .reply-input {
        height: 36px;
    }
}

@media (max-width: 640px) {
    .app-topbar-logo {
        height: 22px;
    }

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

    .tool-btn {
        font-size: 11px;
        padding: 0 7px;
    }
}
