/* Responsive Layout Rules */

@media (max-width: 800px) {
    /* ------------------------------------------------------------------
       1. GLOBAL RESET & UTILITIES
       ------------------------------------------------------------------ */

    /* Hide desktop-only decorations */
    .right-column {
        display: none !important;
    }

    /* ------------------------------------------------------------------
       2. MAIN CONTAINER ADAPTATION
       ------------------------------------------------------------------ */

    /* Reset margins and widths for the main journal container */
    body.journal-page .single-column {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: var(--content-padding) !important;
        padding-bottom: calc(var(--mobile-header-height) + 5rem) !important;
        /* Increased spacing for bottom toolbar + footer */
        flex: 1;
    }

    /* Reset margins for admin panel */
    body.admin-page main {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 1rem !important;
        padding-bottom: calc(var(--mobile-header-height) + 2rem) !important;
    }

    /* Disable huge side margins on very large screens override */
    @media (min-width: 1500px) {
        body.journal-page .single-column {
            margin: 0 !important;
            /* Ensure our mobile rule persists if screens are weirdly detected */
        }
    }

    /* ------------------------------------------------------------------
       3. NAVIGATION TOOLBAR (Bottom Bar)
       ------------------------------------------------------------------ */

    .toolbar {
        position: fixed;
        top: auto !important;
        /* Override layout.css top: 1rem */
        bottom: 0;
        left: 0;
        right: 0;
        width: 100% !important;
        /* Override 62px */
        height: var(--mobile-header-height) !important;
        flex-direction: row !important;
        justify-content: space-evenly;
        align-items: center;
        background: rgba(255, 255, 255, 0.95);
        border-top: 1px solid var(--accent-gray);
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
        /* Upward shadow */
        padding: 0 !important;
        z-index: 9999;
        backdrop-filter: blur(8px);
    }

    .toolbar-btn {
        width: 100% !important;
        max-width: none !important;
        height: 100% !important;
        border: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        color: var(--text-secondary);
        position: relative;
    }

    /* Active state or Hover on mobile */
    .toolbar-btn:active {
        background: rgba(0, 0, 0, 0.05) !important;
    }

    /* Icon adjustments */
    .toolbar-btn svg {
        width: 24px;
        height: 24px;
        margin: 0;
    }

    /* Hide tooltip spans on mobile, they don't work with touch */
    .toolbar-btn span {
        display: none !important;
    }

    /* Language flag specific handling */
    .toolbar-btn.languages:hover {
        width: 100% !important;
        /* Prevent expansion width change */
    }

    .toolbar-btn.languages .flags {
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        background: white;
        padding: 0.5rem;
        border: 1px solid var(--accent-gray);
        border-radius: 8px;
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
        margin: 0 0 10px 0;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s;
        display: flex;
        gap: 1rem;
    }

    /* Use a click or focus to show flags? For now, we might leave it simple or rely on JS to toggle class */
    .toolbar-btn.languages:focus-within .flags {
        opacity: 1;
        pointer-events: auto;
    }

    /* Footer Adjustment */
    footer {
        padding-bottom: calc(var(--mobile-header-height) + 2rem) !important;
    }
}