/* App Layout Integration with Enhanced Navigation */

/* Main Layout Structure */
body {
    margin: 0;
    padding: 0;
    /* FIXED: Removed overflow: hidden - now handled in styles.css with proper mobile scrolling */
    /* overflow: hidden; -- REMOVED for mobile scrolling */
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

/* App Container for proper layout */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Main Content Area with Navigation Adjustment */
.main-content {
    position: fixed;
    left: var(--nav-width-expanded, 240px);
    right: 0;
    top: 0;
    bottom: 0;
    width: calc(100vw - var(--nav-width-expanded, 240px));
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: auto;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    margin: 0 !important; /* CRITICAL FIX: Prevent any margin that causes gap */
}

/* When navigation is collapsed */
.nav-sidebar.is-collapsed ~ .main-content,
body:has(.nav-sidebar.is-collapsed) .main-content {
    left: var(--nav-width-collapsed, 60px);
    width: calc(100vw - var(--nav-width-collapsed, 60px));
}

/* Dynamic Content Sections Container */
.content-sections {
    flex: 1;
    padding: clamp(1rem, 3vw, 3rem);
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 100%;
}

/* Dashboard Section with Three.js Background */
#dashboard-section {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    display: block;
}

/* Three.js Canvas Container */
#three-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* Dynamic Welcome Card */
.welcome-card {
    position: relative;
    z-index: 1;
    width: calc(100% - 2rem);
    max-width: min(90%, 600px);
    margin: clamp(2rem, 5vh, 4rem) auto;
    padding: clamp(1.5rem, 4vw, 3rem);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: clamp(15px, 2vw, 25px);
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.welcome-card h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    margin-bottom: clamp(0.75rem, 2vw, 1.5rem);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.welcome-card p {
    color: rgba(255, 255, 255, 0.9);
    font-size: clamp(1rem, 2vw, 1.2rem);
    line-height: 1.6;
    margin-bottom: clamp(1.5rem, 3vw, 2rem);
}

.welcome-card ul {
    text-align: left;
    max-width: 400px;
    margin: 0 auto 2rem;
    list-style: none;
    padding: 0;
}

.welcome-card ul li {
    color: rgba(255, 255, 255, 0.8);
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.welcome-card ul li:before {
    content: "•";
    color: #6366f1;
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* Profile Button with Glassmorphism */
.button.is-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.button.is-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

/* Enhanced Responsive Design System */

/* Extra Small Devices (phones, < 576px) */
@media (max-width: 575px) {
    .main-content {
        left: 0 !important; /* CRITICAL FIX: Override fixed positioning */
        width: 100vw !important; /* Use full viewport width */
        margin-left: 0;
        padding-top: 60px; /* Space for mobile header */
    }

    .nav-sidebar.is-collapsed ~ .main-content {
        left: 0 !important;
        margin-left: 0;
    }

    .content-sections {
        padding: 0.75rem;
    }

    .welcome-card {
        margin: 1rem;
        padding: 1.5rem;
        border-radius: 15px;
    }

    .welcome-card h1 {
        font-size: 1.75rem;
    }

    .welcome-card p {
        font-size: 1rem;
    }

    .profiles-grid {
        grid-template-columns: 1fr;
    }

    #dashboard-section {
        min-height: calc(100vh - 80px);
    }
}

/* Small Devices (landscape phones, 576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .main-content {
        left: 0 !important; /* CRITICAL FIX: Override fixed positioning */
        width: 100vw !important; /* Use full viewport width */
        margin-left: 0;
        padding-top: 60px;
    }

    .content-sections {
        padding: 1rem;
    }

    .welcome-card {
        margin: 1.5rem;
        padding: 2rem;
    }

    .welcome-card h1 {
        font-size: 2rem;
    }

    .profiles-grid {
        grid-template-columns: 1fr;
    }
}

/* Medium Devices (tablets, 768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .main-content {
        margin-left: var(--nav-width-collapsed);
        transition: margin-left 0.3s ease;
    }

    .nav-sidebar.is-expanded ~ .main-content {
        margin-left: var(--nav-width-expanded);
    }

    .content-sections {
        padding: 1.5rem;
    }

    .welcome-card {
        margin: 2rem auto;
        max-width: 500px;
    }

    .profiles-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1rem;
    }
}

/* Large Devices (desktops, 992px - 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .main-content {
        margin-left: var(--nav-width-expanded);
    }

    .nav-sidebar.is-collapsed ~ .main-content {
        margin-left: var(--nav-width-collapsed);
    }

    .content-sections {
        padding: 2rem;
        max-width: 1100px;
        margin: 0 auto;
    }

    .profiles-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* Extra Large Devices (large desktops, 1200px - 1919px) */
@media (min-width: 1200px) and (max-width: 1919px) {
    .content-sections {
        padding: 2rem 3rem;
        max-width: 1400px;
        margin: 0 auto;
    }

    .welcome-card {
        max-width: 700px;
    }

    .profiles-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 2rem;
    }
}

/* Ultra Wide Screens (4K monitors, >= 1920px) */
@media (min-width: 1920px) {
    .content-sections {
        padding: 3rem 4rem;
        max-width: 1800px;
        margin: 0 auto;
    }

    .welcome-card {
        max-width: 800px;
        padding: 4rem;
    }

    .welcome-card h1 {
        font-size: 3rem;
    }

    .profiles-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        gap: 2.5rem;
    }

    .profile-card {
        padding: 2rem;
    }
}

/* Chart Visualization Container */
.chart-container,
#chartContainer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, rgba(99, 102, 241, 0.1), transparent);
    overflow: hidden;
}

/* Ensure Three.js renders properly */
canvas#three-canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
}

/* Hide old navigation elements */
.columns.is-fullheight.is-gapless {
    display: none;
}

/* Override Bulma column styles for new layout */
.column.is-narrow {
    display: none;
}

/* Profile and Chat sections */
#profiles-section,
#chat-sessions,
#settings-section {
    display: none;
    animation: fadeIn 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 100vh;
    width: 100%;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    overflow-y: auto;
}

/* When sections are inside main-content, they inherit the margin */
.main-content #profiles-section,
.main-content #chat-sessions,
.main-content #settings-section {
    margin-left: 0;
    padding: 2rem;
    width: 100%;
    max-width: 100%;
}

#profiles-section.active,
#chat-sessions.active,
#settings-section.active {
    display: block;
    width: 100%;
}

/* Profiles section specific */
#profiles-section {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    display: flex;
    flex-direction: column;
}

/* Container fluid for full width - Override inline styles */
#profiles-section .container.is-fluid,
#profiles-section .container,
.main-content #profiles-section .container.is-fluid,
.main-content #profiles-section .container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 1rem !important;
}

/* Ensure profile cards reflow properly */
.profiles-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 1.5rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ensure modals appear above navigation */
.modal,
.auth-modal,
.logout-modal {
    z-index: 10000;
}

/* Dynamic Profile Grid Layout */
.profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 350px), 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
    padding: 0;
    width: 100%;
    container-type: inline-size;
}

.profile-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.profile-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* Make sure page title is visible */
#page-title {
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
}