/* Import premium Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

/* Professional Dark Mode & Glassmorphism Design Tokens */
:root {
    --bg-main: #050505;
    --bg-sidebar: rgba(10, 10, 12, 0.7);
    --bg-card: rgba(20, 20, 25, 0.4);
    --bg-input: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --accent: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.5);
    --accent-hover: #7c3aed;
    --border: rgba(255, 255, 255, 0.05);
    --glass-blur: blur(24px);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    --font-sans: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Custom Webkit scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
}

.app-container {
    display: flex;
    width: 100%;
    height: calc(100vh - 72px);
    margin-top: 72px;
}

/* 1. SIDEBAR DESIGN */
.sidebar {
    width: 280px;
    height: calc(100% - 32px);
    margin: 16px;
    border-radius: 24px;
    background-color: rgba(15, 15, 18, 0.95);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    padding: 0 8px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px var(--accent-glow);
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(to right, #f8fafc, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.navigation-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-link.active {
    color: var(--accent);
    border-left: 3px solid var(--accent);
    box-shadow: -2px 0 10px var(--accent-glow);
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.1), transparent);
}

.nav-link ion-icon {
    font-size: 18px;
}

.conversations-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.conversations-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-left: 12px;
    font-weight: 600;
}

.conv-item {
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.conv-item:hover, .conv-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.conv-item.active {
    color: var(--text-primary);
    font-weight: 500;
}

.user-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 8px 0;
    border-top: 1px solid var(--border);
    margin-top: 16px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-family: var(--font-heading);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-status {
    font-size: 12px;
    color: #10b981;
}

/* 2. MAIN WORK AREA */
.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.chat-header {
    display: none; /* Removed internal header to use global top nav */
}

.top-nav {
    height: 72px;
    border-bottom: 1px solid var(--border);
    background: rgba(5, 5, 5, 0.6);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
}

.header-title-container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 24px;
}

.header-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
}

.status-badge {
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
}

.status-dot.active {
    background: #10b981;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
    animation: pulse 2s infinite;
}

.status-dot.connecting {
    background: #f59e0b;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.6);
    animation: pulse 1.5s infinite;
}

.status-dot.offline {
    background: #ef4444;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(1); opacity: 0.8; }
}

/* 3. SPLIT STUDIO PANEL */
.flow-studio-container {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
    position: relative;
}

.flow-gallery-section {
    flex-grow: 1;
    padding: 32px;
    overflow-y: auto;
}

.flow-gallery-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 24px;
}

.flow-gallery-header h3 {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 600;
}

.gallery-sub-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 32px 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.gallery-sub-header span {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 500;
}

/* Gallery Grid System */
.flow-gallery-grid {
    columns: 3 320px;
    column-gap: 24px;
    display: block;
}

.gallery-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    break-inside: avoid;
    margin-bottom: 24px;
    display: inline-block;
    width: 100%;
}

.gallery-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.gallery-card img, .gallery-card video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.gallery-card:hover img, .gallery-card:hover video {
    transform: scale(1.05);
}

.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 32px 16px 16px;
    background: linear-gradient(to top, rgba(0,0,0,0.95), transparent);
    color: #fff;
    opacity: 1; /* Changed to always visible */
    pointer-events: none;
}

.gallery-card:hover .card-overlay {
    opacity: 1;
}

.card-prompt-text {
    font-size: 13px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.flow-card-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--border);
    border-radius: 16px;
    grid-column: 1 / -1;
}

/* 4. FLOATING PROMPT BAR (Replaces Controls Panel) */
.floating-prompt-wrapper {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.floating-prompt-form {
    width: 100%;
    background: rgba(15, 15, 18, 0.95);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 12px 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.prompt-input-area textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 16px;
    resize: none;
    padding: 12px 8px;
    outline: none;
    overflow-y: hidden;
    min-height: 48px;
}

.prompt-input-area textarea::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.prompt-bottom-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.left-controls, .right-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.prompt-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s;
    border: 1px solid transparent;
}
.prompt-icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

.prompt-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
}
.prompt-chip:hover {
    background: rgba(255, 255, 255, 0.1);
}

.prompt-submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 20px;
    transition: transform 0.2s;
    box-shadow: 0 4px 15px var(--accent-glow);
}
.prompt-submit-btn:hover {
    transform: scale(1.05);
}
.prompt-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Advanced Options Popup */
.advanced-options-popup {
    background: rgba(15, 15, 18, 0.95);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transform-origin: bottom center;
    animation: slideUpFade 0.2s ease-out forwards;
}

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

.provider-selector, .preset-grid, .modifiers-flex {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.provider-btn, .preset-btn, .modifier-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.provider-btn:hover, .preset-btn:hover, .modifier-pill:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.provider-btn.active, .preset-btn.active, .modifier-pill.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1050;
    display: flex;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    opacity: 1;
    pointer-events: all;
}

.lightbox-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
}

.lightbox-content {
    margin: auto;
    width: 90%;
    max-width: 1200px;
    display: flex;
    gap: 32px;
    align-items: center;
}

.lightbox-media-wrapper {
    flex: 2;
    display: flex;
    justify-content: center;
}

.lightbox-media-wrapper img, .lightbox-media-wrapper video {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.lightbox-details {
    flex: 1;
    background: var(--bg-card);
    padding: 32px;
    border-radius: 16px;
    border: 1px solid var(--border);
}

/* --- MOBILE RESPONSIVE MEDIA QUERIES --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 90;
}

@media (max-width: 1024px) {
    .flow-control-panel {
        width: 320px;
        padding: 24px 16px;
    }
    .flow-gallery-grid {
        columns: 2 220px;
    }
}

@media (max-width: 850px) {
    .app-container {
        flex-direction: column;
    }
    .menu-toggle-btn {
        display: block;
    }
    .sidebar {
        position: fixed;
        left: -280px;
        z-index: 100;
    }
    .sidebar.active {
        left: 0;
    }
    .sidebar-overlay.active {
        display: block;
    }
    
    .flow-studio-container {
        flex-direction: column;
        overflow-y: auto;
    }
    
    .flow-gallery-section {
        padding: 16px;
        overflow-y: visible;
    }
    
    .flow-control-panel {
        width: 100%;
        border-left: none;
        border-top: none;
        border-bottom: 1px solid var(--border);
        padding: 24px 16px;
        order: -1; /* Push prompt box to the top on mobile */
    }
    
    .lightbox-content {
        flex-direction: column;
        padding-top: 60px;
        overflow-y: auto;
        max-height: 100vh;
    }
    
    .top-nav {
        padding: 0 16px;
    }
    .status-badge {
        display: none;
    }
    .user-info {
        display: none;
    }
}

@media (max-width: 480px) {
    .flow-gallery-grid {
        columns: 1 auto;
    }
    .flow-control-panel {
        padding: 16px 12px;
    }
    .lightbox-content {
        padding-top: 20px;
        width: 100%;
        margin: 0;
    }
}

/* Chat interface specific */
.input-panel {
    padding: 20px;
    background: rgba(15, 17, 26, 0.8);
    backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border);
}

.input-container {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.action-btn.send-btn {
    background: var(--accent);
    color: #fff;
    border-radius: 12px;
    width: 40px;
    height: 40px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* =========================================
   PREMIUM STUDIO UPGRADES (Animations & Glass)
   ========================================= */

/* Dynamic Mesh Background */
.mesh-gradient-dynamic {
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(79, 70, 229, 0.2), transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.2), transparent 50%),
        radial-gradient(circle at 50% 80%, rgba(6, 182, 212, 0.15), transparent 50%);
    background-size: 200% 200%;
    animation: meshShift 15s ease infinite;
}

@keyframes meshShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Refined Glass Panel */
.glass-panel-premium {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.05);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease, border-color 0.4s ease;
}

.glass-panel-premium:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Entrance Animations */
.animate-fade-in-up {
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }

/* Glowing Text */
.text-glow {
    text-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

/* Magnetic Button Hover Effect */
.btn-magnetic {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}
.btn-magnetic:active {
    transform: scale(0.95) !important;
}

/* Chat Message Bubbles Refined */
.msg-bubble-user {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border: 1px solid rgba(99, 102, 241, 0.3);
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.1);
    border-radius: 20px 20px 4px 20px;
}

.msg-bubble-ai {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    border-radius: 20px 20px 20px 4px;
}

.submit-btn {
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4);
}

.submit-btn:active {
    transform: translateY(0);
}

@keyframes pulse {
    0% { opacity: 0.3; transform: scale(0.9); }
    50% { opacity: 0.7; transform: scale(1.1); }
    100% { opacity: 0.3; transform: scale(0.9); }
}
