/* Mobile-first shell styles. Desktop layout remains defined by layout.css. */

.desktop-only {
    display: flex;
}

.mobile-only {
    display: none;
}

.mobile-nav-backdrop {
    display: none;
}

.mobile-nav {
    display: none;
}

.bottom-nav {
    display: none;
}

.footer-mobile {
    display: none;
}

.header-actions-mobile {
    display: none;
}

.header-actions-desktop {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

@media (max-width: 900px) {
    .desktop-only,
    .header-actions-desktop {
        display: none !important;
    }

    .footer-desktop {
        display: none !important;
    }

    .footer-mobile {
        display: block !important;
    }

    .mobile-only {
        display: flex;
    }

    .header-inner {
        height: 56px;
        gap: var(--space-3);
    }

    .header-logo img {
        height: 26px;
    }

    .header-actions-mobile {
        display: flex;
        align-items: center;
        gap: var(--space-2);
    }

    .mobile-account-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-full);
        overflow: hidden;
    }

    .mobile-account-link .user-avatar,
    .mobile-account-link .user-avatar-placeholder {
        width: 26px;
        height: 26px;
    }

    .button-compact {
        min-height: 34px;
        padding: 6px 10px;
        font-size: var(--text-sm);
    }

    .mobile-menu-trigger {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        width: 38px;
        height: 38px;
        padding: 0;
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-base);
        background: transparent;
        cursor: pointer;
    }

    .mobile-menu-trigger span {
        display: block;
        width: 18px;
        height: 2px;
        margin: 0 auto;
        background: var(--text-secondary);
        transition: transform var(--transition-fast), opacity var(--transition-fast), background var(--transition-fast);
    }

    .mobile-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.62);
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-base);
        z-index: 140;
    }

    .mobile-nav {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(86vw, 360px);
        max-width: 100%;
        background: var(--bg-secondary);
        border-left: 1px solid var(--border-subtle);
        transform: translateX(100%);
        transition: transform var(--transition-base);
        z-index: 150;
        overflow: hidden;
    }

    body.mobile-nav-open {
        overflow: hidden;
    }

    body.mobile-nav-open .mobile-nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    body.mobile-nav-open .mobile-nav {
        transform: translateX(0);
    }

    .mobile-nav-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-3);
        min-height: 56px;
        padding: 0 var(--space-4);
        border-bottom: 1px solid var(--border-subtle);
    }

    .mobile-nav-body {
        flex: 1 1 auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: var(--space-3) var(--space-4) var(--space-6);
    }

    .mobile-nav-link {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: var(--space-3) 0;
        color: var(--text-secondary);
        font-size: var(--text-md);
        font-weight: 500;
        border-bottom: 1px solid var(--border-subtle);
        text-decoration: none;
    }

    .mobile-nav-link:hover,
    .mobile-nav-link:focus-visible {
        color: var(--text-primary);
    }

    .mobile-nav-link.is-active {
        color: var(--text-primary);
    }

    .mobile-nav-primary {
        color: var(--bg-primary);
        background: var(--accent-primary);
        border: none;
        border-radius: var(--radius-base);
        justify-content: center;
        margin-top: var(--space-2);
    }

    .mobile-nav-button {
        width: 100%;
        border: none;
        background: transparent;
        text-align: left;
        cursor: pointer;
    }

    .mobile-nav-divider {
        height: 1px;
        margin: var(--space-3) 0;
        background: var(--border-subtle);
    }

    .mobile-nav-group {
        border-bottom: 1px solid var(--border-subtle);
    }

    .mobile-nav-group > summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 44px;
        padding: var(--space-3) 0;
        color: var(--text-tertiary);
        font-size: var(--text-sm);
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        cursor: pointer;
        list-style: none;
    }

    .mobile-nav-group > summary::-webkit-details-marker {
        display: none;
    }

    .mobile-nav-group > summary::after {
        content: "+";
        color: var(--text-muted);
        font-size: var(--text-lg);
        line-height: 1;
    }

    .mobile-nav-group[open] > summary::after {
        content: "−";
    }

    .mobile-nav-group .mobile-nav-link {
        padding-left: var(--space-4);
        font-size: var(--text-base);
        font-weight: 400;
        text-transform: none;
        letter-spacing: 0;
        color: var(--text-secondary);
    }

    .mobile-nav-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-base);
        background: transparent;
        cursor: pointer;
    }

    .mobile-nav-close span {
        position: absolute;
        width: 18px;
        height: 2px;
        background: var(--text-secondary);
    }

    .mobile-nav-close span:first-child {
        transform: rotate(45deg);
    }

    .mobile-nav-close span:last-child {
        transform: rotate(-45deg);
    }

    .mobile-nav-close {
        position: relative;
    }

    /* Bottom navigation */
    .bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 130;
        align-items: stretch;
        min-height: 58px;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-subtle);
        box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
    }

    .bottom-nav-item {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-height: 44px;
        color: var(--text-muted);
        font-size: var(--text-xs);
        text-decoration: none;
        transition: color var(--transition-fast), background var(--transition-fast);
        border-radius: var(--radius-base);
    }

    .bottom-nav-item svg {
        width: 20px;
        height: 20px;
    }

    .bottom-nav-item span {
        line-height: 1;
        white-space: nowrap;
    }

    .bottom-nav-item:hover,
    .bottom-nav-item:focus-visible {
        color: var(--text-primary);
        background: var(--bg-hover);
    }

    .bottom-nav-item.is-active {
        color: var(--text-primary);
    }

    body {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }

    body.app-page {
        padding-bottom: 0;
    }

    body.app-page .bottom-nav {
        display: none !important;
    }

    /* Footer */
    .footer {
        margin-top: var(--space-12);
        padding: var(--space-8) 0 calc(var(--space-8) + 4px);
    }

    .footer-top {
        display: grid;
        grid-template-columns: 1fr;
        gap: var(--space-6);
        margin-bottom: var(--space-6);
    }

    .footer-links {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0;
    }

    .footer-group {
        border-bottom: 1px solid var(--border-subtle);
    }

    .footer-group > summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 44px;
        color: var(--text-secondary);
        font-size: var(--text-base);
        font-weight: 600;
        cursor: pointer;
        list-style: none;
    }

    .footer-group > summary::-webkit-details-marker {
        display: none;
    }

    .footer-group > summary::after {
        content: "+";
        color: var(--text-muted);
    }

    .footer-group[open] > summary::after {
        content: "−";
    }

    .footer-group-body {
        display: none;
        flex-direction: column;
        gap: var(--space-3);
        padding: 0 0 var(--space-4);
    }

    .footer-group[open] .footer-group-body {
        display: flex;
    }

    .footer-bottom {
        flex-direction: column;
        gap: var(--space-4);
        text-align: center;
    }

    .footer-legal {
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--space-3);
    }

    /* Generic mobile safety */
    .container,
    .container-wide {
        width: min(100%, calc(100% - 24px));
    }

    .row,
    .row-between {
        flex-wrap: wrap;
    }

    .list-item {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }

    .table,
    .project-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .admin-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: var(--space-2);
    }

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

}

@media (min-width: 901px) {
    .mobile-only {
        display: none !important;
    }

    .footer-desktop {
        display: block !important;
    }

    .footer-mobile {
        display: none !important;
    }

    .footer-group > summary {
        display: block;
        cursor: default;
        color: var(--text-secondary);
        font-size: var(--text-base);
        font-weight: 600;
        margin-bottom: var(--space-3);
        list-style: none;
    }

    .footer-group > summary::-webkit-details-marker {
        display: none;
    }

    .footer-group > summary::after {
        content: "";
    }

    .footer-group-body {
        display: flex;
        flex-direction: column;
        gap: var(--space-3);
    }

    .footer-top {
        display: grid;
        grid-template-columns: 1fr 2fr;
        gap: var(--space-12);
        margin-bottom: var(--space-10);
    }

    .footer-links {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-8);
    }
}
