/* assets/css/2-layout.css */

/* App Container - The "OS" Window */
.app-container {
    display: grid;
    grid-template-columns: var(--nav-width) 1fr var(--widget-width);
    grid-template-rows: 100vh;
    min-height: 100vh;
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow: hidden;
    width: 100%;
    max-width: 100vw;
    /* Prevent body scroll, individual panels scroll */
}

/* 1. Left Navigation Rail (Dock) */
.nav-rail {
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* Push top and bottom apart */
    align-items: center;
    padding: 20px 0;
    z-index: 20;
    overflow: hidden;
}

.nav-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.nav-bottom {
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
}

.nav-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    margin-bottom: 40px;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: transform 0.2s;
}

.nav-logo:hover {
    transform: scale(1.05);
    box-shadow: var(--glow-primary);
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 28px;
    width: 100%;
    align-items: center;
}

.nav-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    background: transparent;
    border: none;
}

.nav-icon:hover,
.nav-icon.active {
    background-color: var(--bg-panel-hover);
    color: var(--accent-primary);
}

.nav-icon.active::before {
    content: '';
    position: absolute;
    left: -10px;
    width: 4px;
    height: 24px;
    background-color: var(--accent-primary);
    border-radius: 0 4px 4px 0;
}

.nav-icon i {
    font-size: 24px;
}

.gemini-home {
    background: linear-gradient(135deg, #7c4dff, #5fe1ff);
    color: white;
    box-shadow: var(--shadow-soft);
}

.gemini-home:hover,
.gemini-home.active {
    background: linear-gradient(135deg, #6b3dff, #4ad6ff);
    color: white;
}

/* 2. Main Content Stream */
.main-stream {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 0;
    position: relative;
    width: 100%;
    overflow-x: hidden;
}

/* Header Removed */

.stream-content {
    padding: 40px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    overflow-x: hidden;
}

/* 3. Right Widget Panel */
.widget-panel {
    background-color: var(--bg-panel);
    border-left: 1px solid var(--border-subtle);
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Mobile Adaptation */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: var(--nav-width) 1fr;
        /* Hide widgets on tablet */
    }

    .widget-panel {
        display: none;
        /* Or move to a drawer */
    }
}

@media (max-width: 768px) {
    html, body {
        height: auto;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: 60px 1fr;
        height: auto;
        min-height: 100vh;
        overflow: visible;
        width: 100%;
        max-width: 100vw;
    }

    .nav-rail {
        grid-row: 1;
        flex-direction: row;
        width: 100%;
        height: 60px;
        border-right: none;
        border-top: none;
        border-bottom: 1px solid var(--border-subtle);
        padding: 0 20px;
        justify-content: space-between;
        /* Keep space-between */
    }

    .nav-top {
        flex-direction: row;
        width: auto;
        gap: 20px;
    }

    .nav-bottom {
        flex-direction: row;
        width: auto;
        gap: 14px;
        margin-bottom: 0;
    }

    .nav-logo {
        display: none;
    }

    /* Hide logo in bottom bar to save space */
    .nav-links {
        flex-direction: row;
        gap: 16px;
        justify-content: flex-start;
        width: auto;
    }

    .nav-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .nav-icon.active::before {
        left: 50%;
        bottom: -10px;
        top: auto;
        width: 20px;
        height: 4px;
        transform: translateX(-50%);
        border-radius: 4px 4px 0 0;
    }

    .nav-home-mobile {
        display: flex;
    }

    .nav-icon.active::before {
        left: 50%;
        bottom: -10px;
        top: auto;
        width: 20px;
        height: 4px;
        transform: translateX(-50%);
        border-radius: 4px 4px 0 0;
    }

    .main-stream {
        grid-row: 2;
        overflow: visible;
        min-height: calc(100vh - 60px);
        width: 100%;
        max-width: 100vw;
    }

    .stream-content {
        padding: 18px 14px 28px;
        max-width: 100%;
    }
}

/* Focus Mode Styles */
body.focus-mode .nav-rail,
body.focus-mode .widget-panel {
    display: none !important;
}

body.focus-mode .app-container {
    grid-template-columns: 1fr;
    /* Single column */
    grid-template-rows: auto;
    min-height: auto;
    height: auto;
}

body.focus-mode .stream-content,
body.focus-mode .post-detail-clean {
    max-width: 800px;
    /* Optimal reading width */
    margin: 0 auto;
    padding: 40px 20px;
}

/* In reader mode, let the page handle scrolling instead of the main column */
body.focus-mode {
    overflow-y: auto;
}

body.focus-mode .main-stream {
    overflow: visible;
}
