/* --- Variables and Reset --- */
:root {
    --primary-color: #007bff; /* InternAdda Blue */
    --ai-blue: #00c4ff; /* Lighter/Electric Blue for AI elements */
    --ai-bg-dark: #1f2937; /* Dark background for AI feel (used selectively) */
    --background-light: #f4f7f9;
    --card-background: #ffffff;
    --text-dark: #333333;
    --nav-text-color: #555555; 
    --tech-font: 'Roboto Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif; 
    line-height: 1.6;
    background-color: var(--background-light); 
    color: var(--text-dark);
}

.container {
    width: 95%;
    max-width: 1300px;
    margin: 0 auto;
    padding: 10px 0;
}

/* ----------------------------------
 * 1. Header Styling 
 * ---------------------------------- */
.main-header {
    background: var(--card-background);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
}

.logo-area {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo-img {
    height: 35px; 
    width: auto;
    margin-right: 8px;
}

.logo-text {
    font-size: 1.5em;
    font-weight: 600;
    color: #004d99; 
    text-transform: capitalize;
}

.main-nav {
    display: flex;
    align-items: center;
}

.nav-links {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
}

.nav-links li a {
    color: var(--nav-text-color); 
    text-decoration: none;
    padding: 8px 15px;
    display: block;
    transition: color 0.3s;
    font-size: 1.05em;
    font-weight: 400;
}

.nav-links li a:hover, .nav-links li a.active {
    color: var(--text-dark); 
    font-weight: 500;
}

.menu-toggle {
    display: none; /* Hidden on desktop */
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    position: relative;
    z-index: 10;
}

.bar {
    display: block;
    width: 25px;
    height: 3px;
    margin: 5px auto;
    background-color: var(--text-dark);
    transition: all 0.3s ease-in-out;
}

/* ----------------------------------
 * 2. AI Vibe & Hero Section 
 * ---------------------------------- */

.ai-playground-content {
    padding: 20px 0;
}

.hero-section {
    /* Slightly more electric gradient for AI feel */
    background: linear-gradient(135deg, #e0f7fa, #b3e5fc); 
    border: 1px solid var(--ai-blue);
    padding: 50px 20px;
    margin-bottom: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    text-align: center;
}

.hero-section h2 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 2.2em;
    font-weight: 700;
}

/* Tech/Code style for visual elements */
.code-style {
    font-family: var(--tech-font);
    color: var(--ai-blue);
    font-size: 0.9em;
    font-weight: 700;
    background: #00000010;
    padding: 2px 4px;
    border-radius: 3px;
}

/* ----------------------------------
 * 3. Search Bar Styling 
 * ---------------------------------- */

.search-bar-container {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    background: var(--card-background);
    border-radius: 25px; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

#prompt-search {
    flex-grow: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 25px 0 0 25px;
    font-size: 1em;
    outline: none;
}

#search-button {
    background: var(--ai-blue); 
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 1em;
    border-radius: 0 25px 25px 0;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    font-weight: 600;
    box-shadow: 0 0 5px var(--ai-blue);
}

#search-button:hover {
    background: #0099cc;
    box-shadow: 0 0 8px #0099cc;
}


/* ----------------------------------
 * 4. Gallery Section (Prompt Truncation)
 * ---------------------------------- */

.ai-gallery h3 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-dark);
    font-weight: 700;
    font-size: 1.8em;
}

.gallery-grid {
    /* Set to 4 columns for large desktop as requested */
    display: grid;
    grid-template-columns: repeat(4, 1fr); 
    gap: 30px;
}

.ai-post {
    background: var(--card-background);
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer; /* NEW: Indicate clickability for the whole card */
}

.ai-post:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.ai-post img {
    width: 100%;
    height: 250px; 
    object-fit: cover;
    display: block;
    border-bottom: 1px solid #eee;
}

.post-details {
    padding: 12px 15px; 
}

.ai-post h4 {
    margin-bottom: 10px;
    color: var(--primary-color);
    font-size: 1.2em;
}

/* New: Wrapper for truncation */
.prompt-area {
    position: relative;
    padding: 10px 0;
    border-top: 1px dashed #ddd;
    border-bottom: 1px dashed #ddd;
    margin-bottom: 10px;
}

.prompt-text {
    font-family: var(--tech-font);
    font-style: italic;
    font-size: 0.85em;
    color: #666;
    /* Truncation CSS: Limit to 3 lines (approx. 4.5em) */
    max-height: 4.5em; 
    overflow: hidden;
    position: relative;
    transition: max-height 0.3s ease-out;
    margin-bottom: 0;
}

/* Fade out effect over truncated text - REMOVED FOR CLEANER LOOK */
.prompt-area::after {
    display: none;
}

/* The button and its styles are removed from HTML and CSS */
.show-full-prompt-btn {
    display: none;
}

.post-meta {
    font-size: 0.85em;
    color: #999;
}

/* View More Button Styling */
.load-more-container {
    text-align: center;
    margin-top: 40px;
}

#load-more-posts {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.05em;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s, opacity 0.3s; 
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto; 
}

#load-more-posts:hover:not(.loading) {
    background: #0056b3;
    transform: translateY(-2px);
}

/* Loading State for professional animation */
#load-more-posts.loading {
    pointer-events: none; 
    opacity: 0.8;
    background: #0056b3;
    min-width: 200px; 
}

/* Spinner Animation CSS */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    display: none;
}

#load-more-posts.loading .spinner {
    display: block;
}

#load-more-posts.loading .button-text {
    visibility: hidden; 
}

/* ----------------------------------
 * 5. Footer Styling (Updated for Professionalism & Socials)
 * ---------------------------------- */

.main-footer {
    background: var(--ai-bg-dark); /* Darker background for better contrast */
    color: white;
    padding: 30px 0;
    text-align: center;
    margin-top: 50px;
}

.footer-sections {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15); /* Subtle separator */
    margin-bottom: 20px;
    flex-wrap: wrap; 
}

.footer-links {
    margin-bottom: 10px; /* Space for wrap */
}

.footer-links a {
    color: #a0c4ff;
    text-decoration: none;
    margin: 0 15px;
    font-size: 0.9em;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: var(--primary-color);
}

/* Social Links Styling */
.social-links {
    display: flex;
    gap: 18px;
    margin-top: 10px;
}

.social-link {
    color: #ddd; /* Lighter icon color */
    font-size: 1.4em;
    transition: color 0.3s, transform 0.3s;
}

.social-link:hover {
    color: var(--ai-blue); 
    transform: scale(1.1);
}

.main-footer p {
    margin-top: 0;
    font-size: 0.8em;
    color: #aaa;
}

/* ----------------------------------
 * 7. Modal (Popup) Styling - UPDATED FOR SPLIT VIEW
 * ---------------------------------- */

.modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 100; /* High z-index to cover everything */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.8); /* Darker backdrop for focus */
    padding-top: 50px; 
}

.modal-content {
    background-color: var(--card-background);
    margin: 5% auto; /* 5% from the top and centered */
    padding: 30px;
    border-radius: 12px;
    width: 90%; 
    max-width: 1000px; /* Increased max-width for the split view */
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    position: relative;
    max-height: 90vh; /* Prevent modal from being too tall */
    overflow-y: auto; /* Enable scrolling inside if content is too long */
}

.modal-body-content {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.modal-image-container {
    flex: 1; /* Takes up 1 part of the space (smaller side) */
    border-radius: 8px;
    overflow: hidden;
    max-height: 550px; /* Limit image height for large screens */
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.modal-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.modal-details {
    flex: 2; /* Takes up 2 parts of the space (larger side for text) */
}

/* Post Title inside Modal */
#modal-post-title {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.8em;
    font-weight: 700;
    padding-bottom: 5px;
    border-bottom: 2px solid var(--ai-blue); /* Professional separator */
}

.prompt-text-modal {
    /* Removed redundant H4 style, now using #modal-post-title */
    padding-top: 10px; 
}

/* FIX: Target the code style span inside the modal to remove padding/background and fix alignment */
.prompt-text-modal .code-style {
    background: none;
    padding: 0;
    margin-bottom: 5px; 
    font-size: 1em; 
    color: var(--ai-blue);
    font-weight: 700;
    /* THIS FIXES THE HORIZONTAL SPACE ISSUE by forcing the text below it */
    display: block; 
}

/* Close Button */
.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 20px;
    transition: color 0.2s;
}

.close-btn:hover,
.close-btn:focus {
    color: var(--text-dark);
    text-decoration: none;
    cursor: pointer;
}

/* ----------------------------------
 * 6. Mobile Responsiveness 
 * ---------------------------------- */

@media (max-width: 1200px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .main-header .container {
        padding: 10px 0;
    }
    
    .logo-img {
        height: 30px;
    }

    .logo-text {
        font-size: 1.3em;
    }

    .menu-toggle {
        display: block;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 60px; 
        right: 0;
        width: 100%;
        background: var(--card-background);
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        z-index: 5;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links li {
        width: 100%;
        border-bottom: 1px solid #f0f0f0;
    }
    .nav-links li:last-child {
        border-bottom: none;
    }
    
    .nav-links li a {
        padding: 15px 20px;
        color: var(--text-dark);
    }
    .nav-links li a.active {
        background: #f8f8f8;
        color: var(--primary-color);
        font-weight: 600;
    }
    
    .search-bar-container {
        flex-direction: column;
        border-radius: 8px;
    }

    #prompt-search {
        border-radius: 8px;
        margin-bottom: 10px;
    }

    #search-button {
        border-radius: 8px;
        width: 100%;
    }
    
    /* --- NEW/ADJUSTED MOBILE STYLES FOR COMPACTNESS AND UI --- */

    /* Hero Section: Reduced padding for more vertical space */
    .hero-section {
        padding: 30px 15px; 
        margin-bottom: 20px;
    }

    .hero-section h2 {
        font-size: 1.8em;
    }

    /* Gallery Grid: Maintained 2-column layout but reduced gap */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr); 
        gap: 12px; /* Reduced gap for compactness */
    }
    
    /* AI Post: Tighter card design */
    .ai-post {
        border-radius: 8px;
        box-shadow: 0 3px 8px rgba(0,0,0,0.08); /* Lighter shadow */
    }

    .ai-post img {
        height: 150px; /* Reduced height for more screen space */
        border-radius: 8px 8px 0 0; /* Apply top border radius to image */
        border-bottom: none; /* Remove redundant border */
    }

    .post-details {
        padding: 8px; /* Further reduced padding */
    }

    .ai-post h4 {
        font-size: 1em; /* Reduced heading size */
        margin-bottom: 5px;
    }
    
    /* Prompt Area: More compact wrapper */
    .prompt-area {
        padding: 5px 0;
        margin-bottom: 5px;
    }

    .prompt-text {
        font-size: 0.75em; /* Smaller font for compactness */
        max-height: 3.5em; /* Adjusted max-height for ~3 lines */
    }

    .post-meta {
        font-size: 0.75em; /* Smaller meta text */
    }

    /* Load More Button */
    #load-more-posts {
        padding: 10px 20px;
        font-size: 0.9em;
    }

    /* MODAL MOBILE STYLES: Stack content vertically */
    .modal-content {
        margin: 10% auto;
        padding: 20px;
    }
    
    .modal-body-content {
        flex-direction: column;
        gap: 15px;
    }

    .modal-image-container {
        max-height: 250px;
    }

    #modal-post-title {
        font-size: 1.5em;
    }
    
    /* Footer stacking on mobile */
    .footer-sections {
        flex-direction: column;
    }

    .footer-links {
        margin-bottom: 15px;
    }
    
    .social-links {
        margin-top: 10px;
        margin-bottom: 10px;
    }
}

/* Single column for very small screens (phones) */
@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }
    /* Increase image height for single column to look better */
    .ai-post img {
        height: 200px;
    }
    .footer-sections {
        flex-direction: column;
        align-items: center;
    }
    .footer-links a {
        display: block;
        margin: 5px 0;
    }
}
