/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f7f9fc;
    color: #333;
    line-height: 1.6;
    padding-top: 90px; /* To avoid overlap with fixed header */
}

/* General smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Landing Container - Search Section */
.search-section {
    max-width: 1100px;
    margin: 4rem auto 6rem auto;
    padding: 0 1rem;
    text-align: center;
}

.search-section h2 {
    color: #2a3a7b;
    font-weight: 700;
    font-size: 2.25rem;
    margin-bottom: 2.5rem;
    text-align: center;
}

.search-container {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
    border-radius: 50px;
    overflow: hidden;
    border: 1.5px solid #6e8efb;
    box-shadow: 0 3px 8px rgba(110, 142, 251, 0.3);
    background: #fff;
    transition: all 0.3s ease;
}

.search-container:hover {
    box-shadow: 0 6px 20px rgba(110, 142, 251, 0.4);
    transform: translateY(-2px);
}

.search-container input {
    flex-grow: 1;
    border: none;
    padding: 14px 25px;
    font-size: 1.1rem;
    outline: none;
    color: #333;
    background: transparent;
}

.search-container input::placeholder {
    color: #a0a0a0;
    font-style: italic;
}

.search-container button {
    background: linear-gradient(135deg, #6e8efb, #5a7df4);
    border: none;
    color: white;
    cursor: pointer;
    padding: 0 30px;
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.search-container button:hover {
    background: linear-gradient(135deg, #5a7df4, #4a6ce8);
    transform: scale(1.05);
}

/* Search Results */
#searchResults {
    margin-top: 2rem;
    max-width: 650px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
    font-size: 1rem;
    color: #444;
    min-height: 60px;
}

/* Recommended Topics Section */
.recommended-topics {
    max-width: 1100px;
    margin: 4rem auto 6rem auto;
    padding: 0 1rem;
}

.recommended-topics h2 {
    text-align: center;
    color: #2a3a7b;
    font-weight: 700;
    font-size: 2.25rem;
    margin-bottom: 2.5rem;
}

/* Grid for topic cards */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 2rem;
}

/* Topic cards */
.topic-card {
    background: linear-gradient(135deg, #f9fbff 0%, #ffffff 100%);
    border-radius: 12px;
    padding: 1.6rem 1.8rem;
    text-decoration: none;
    color: #1f1f1f;
    box-shadow: 0 6px 12px rgba(110, 142, 251, 0.15);
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 140px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(110, 142, 251, 0.1);
}

.topic-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        120deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    transition: 0.5s;
}

.topic-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 14px 30px rgba(110, 142, 251, 0.3);
    border-color: rgba(110, 142, 251, 0.3);
}

.topic-card:hover::before {
    left: 100%;
}

.topic-card h3 {
    margin: 0 0 0.5rem 0;
    color: #4b6ed9;
    font-weight: 700;
    font-size: 1.3rem;
    line-height: 1.2;
    transition: transform 0.3s ease;
}

.topic-card:hover h3 {
    transform: scale(1.05);
}

.topic-card p {
    margin: 0;
    font-size: 0.95rem;
    color: #666;
    line-height: 1.4;
}

/* AI Assistant Section Responsive */
.ai-assistant-section.chat-app-card {
    width: 100%;
    max-width: 1100px;
    margin: 2rem auto;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    min-height: 520px;
    position: relative;
    padding: 0;
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 18px 18px 0 0;
    padding: 1rem 1.2rem;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 600;
    position: relative;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem 1rem 1rem 1rem;
    background: #f7f9fc;
    min-height: 180px;
    max-height: 340px;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    border-bottom: 1px solid #e3e8f0;
}

.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 1rem 1rem 1.1rem 1rem;
    background: #fff;
    border-radius: 0 0 18px 18px;
    border-top: 1px solid #e3e8f0;
    position: relative;
}

.chat-input-bar input[type="text"] {
    flex: 1;
    padding: 0.8em 1em;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border 0.2s;
    background: #f7f9fc;
}

.chat-input-bar input[type="text"]:focus {
    border: 2px solid #667eea;
    background: #fff;
}

.send-btn {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.7em 1.3em;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    box-shadow: 0 2px 8px rgba(25,90,205,0.07);
}

.send-btn:hover {
    background: linear-gradient(90deg, #764ba2 0%, #667eea 100%);
}

/* Footer */
footer {
    width: 100%;
    padding: 20px 0;
    font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
    text-align: center;
    background: #fff;
    border-top: 1px solid #e3e8f0;
}

/* Comprehensive Responsive Design */

/* Large Desktop (1200px and up) */
@media (min-width: 1200px) {
    .search-section,
    .recommended-topics,
    .ai-assistant-section.chat-app-card {
        max-width: 1200px;
    }
    
    .topic-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 2.5rem;
    }
    
    .search-section h2,
    .recommended-topics h2 {
        font-size: 2.5rem;
    }
}

/* Desktop (992px - 1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
    .search-section,
    .recommended-topics,
    .ai-assistant-section.chat-app-card {
        max-width: 1000px;
    }
    
    .topic-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 2rem;
    }
}

/* Tablet Landscape (768px - 991px) */
@media (max-width: 991px) and (min-width: 768px) {
    .search-section,
    .recommended-topics,
    .ai-assistant-section.chat-app-card {
        max-width: 90%;
        margin: 3rem auto 4rem auto;
    }
    
    .search-section h2,
    .recommended-topics h2 {
        font-size: 2rem;
        margin-bottom: 2rem;
    }
    
    .search-container {
        max-width: 500px;
    }
    
    .topic-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 1.5rem;
    }
    
    .topic-card {
        padding: 1.4rem 1.6rem;
        min-height: 130px;
    }
    
    .topic-card h3 {
        font-size: 1.2rem;
    }
    
    .topic-card p {
        font-size: 0.9rem;
    }
    
    .chat-history {
        min-height: 200px;
        max-height: 300px;
    }
}

/* Tablet Portrait (600px - 767px) */
@media (max-width: 767px) and (min-width: 600px) {
    .search-section,
    .recommended-topics,
    .ai-assistant-section.chat-app-card {
        max-width: 95%;
        margin: 2.5rem auto 3.5rem auto;
    }
    
    .search-section h2,
    .recommended-topics h2 {
        font-size: 1.8rem;
        margin-bottom: 1.8rem;
    }
    
    .search-container {
        max-width: 100%;
        border-radius: 25px;
    }
    
    .search-container input {
        padding: 12px 20px;
        font-size: 1rem;
    }
    
    .search-container button {
        padding: 0 25px;
        font-size: 1rem;
    }
    
    .topic-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1.2rem;
    }
    
    .topic-card {
        padding: 1.3rem 1.5rem;
        min-height: 120px;
    }
    
    .topic-card h3 {
        font-size: 1.1rem;
    }
    
    .topic-card p {
        font-size: 0.85rem;
    }
    
    .chat-header {
        padding: 0.8rem 1rem;
        font-size: 1.1rem;
    }
    
    .chat-history {
        min-height: 180px;
        max-height: 280px;
        padding: 1rem 0.8rem;
    }
    
    .chat-input-bar {
        padding: 0.8rem 1rem;
    }
    
    .chat-input-bar input[type="text"] {
        padding: 0.7em 0.9em;
        font-size: 0.95rem;
    }
    
    .send-btn {
        padding: 0.6em 1.1em;
        font-size: 0.95rem;
    }
}

/* Mobile Large (480px - 599px) */
@media (max-width: 599px) and (min-width: 480px) {
    .search-section,
    .recommended-topics,
    .ai-assistant-section.chat-app-card {
        max-width: 98%;
        margin: 2rem auto 3rem auto;
        padding: 0 0.5rem;
    }
    
    .search-section h2,
    .recommended-topics h2 {
        font-size: 1.6rem;
        margin-bottom: 1.5rem;
    }
    
    .search-container {
        flex-direction: column;
        border-radius: 15px;
        max-width: 100%;
    }
    
    .search-container input {
        border-radius: 15px 15px 0 0;
        padding: 12px 18px;
        font-size: 1rem;
    }
    
    .search-container button {
        border-radius: 0 0 15px 15px;
        padding: 12px 20px;
        font-size: 1rem;
    }
    
    .topic-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 1rem;
    }
    
    .topic-card {
        padding: 1.2rem 1.4rem;
        min-height: 110px;
    }
    
    .topic-card h3 {
        font-size: 1rem;
        margin-bottom: 0.4rem;
    }
    
    .topic-card p {
        font-size: 0.8rem;
    }
    
    .chat-header {
        padding: 0.7rem 0.8rem;
        font-size: 1rem;
        border-radius: 15px 15px 0 0;
    }
    
    .ai-avatar {
        width: 32px;
        height: 32px;
        font-size: 1.5rem;
        margin-right: 0.5rem;
    }
    
    .ai-title {
        font-size: 1rem;
    }
    
    .chat-history {
        min-height: 160px;
        max-height: 250px;
        padding: 0.8rem 0.7rem;
    }
    
    .chat-input-bar {
        padding: 0.7rem 0.8rem;
        border-radius: 0 0 15px 15px;
    }
    
    .chat-input-bar input[type="text"] {
        padding: 0.6em 0.8em;
        font-size: 0.9rem;
    }
    
    .send-btn {
        padding: 0.5em 1em;
        font-size: 0.9rem;
    }
}

/* Mobile Small (320px - 479px) */
@media (max-width: 479px) {
    .search-section,
    .recommended-topics,
    .ai-assistant-section.chat-app-card {
        max-width: 100%;
        margin: 1.5rem auto 2.5rem auto;
        padding: 0 0.5rem;
    }
    
    .search-section h2,
    .recommended-topics h2 {
        font-size: 1.4rem;
        margin-bottom: 1.2rem;
        line-height: 1.3;
    }
    
    .search-container {
        flex-direction: column;
        border-radius: 12px;
        max-width: 100%;
    }
    
    .search-container input {
        border-radius: 12px 12px 0 0;
        padding: 10px 16px;
        font-size: 0.95rem;
    }
    
    .search-container button {
        border-radius: 0 0 12px 12px;
        padding: 10px 18px;
        font-size: 0.95rem;
    }
    
    .topic-grid {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }
    
    .topic-card {
        padding: 1rem 1.2rem;
        min-height: 100px;
        border-radius: 10px;
    }
    
    .topic-card h3 {
        font-size: 0.95rem;
        margin-bottom: 0.3rem;
    }
    
    .topic-card p {
        font-size: 0.75rem;
        line-height: 1.3;
    }
    
    .chat-header {
        padding: 0.6rem 0.7rem;
        font-size: 0.9rem;
        border-radius: 12px 12px 0 0;
    }
    
    .ai-avatar {
        width: 28px;
        height: 28px;
        font-size: 1.3rem;
        margin-right: 0.4rem;
    }
    
    .ai-title {
        font-size: 0.9rem;
    }
    
    .clear-chat-btn {
        font-size: 1.1rem;
        padding: 0.2em 0.4em;
    }
    
    .chat-history {
        min-height: 140px;
        max-height: 220px;
        padding: 0.6rem 0.5rem;
    }
    
    .chat-bubble {
        padding: 0.6em 0.8em;
        font-size: 0.85rem;
        border-radius: 12px;
    }
    
    .chat-input-bar {
        padding: 0.6rem 0.7rem;
        border-radius: 0 0 12px 12px;
    }
    
    .chat-input-bar input[type="text"] {
        padding: 0.5em 0.7em;
        font-size: 0.85rem;
        border-radius: 6px;
    }
    
    .send-btn {
        padding: 0.4em 0.8em;
        font-size: 0.85rem;
        border-radius: 6px;
    }
    
    footer {
        padding: 15px 0;
        font-size: 0.9rem;
    }
}

/* Extra Small Mobile (below 320px) */
@media (max-width: 319px) {
    .search-section,
    .recommended-topics,
    .ai-assistant-section.chat-app-card {
        margin: 1rem auto 2rem auto;
        padding: 0 0.3rem;
    }
    
    .search-section h2,
    .recommended-topics h2 {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }
    
    .search-container input {
        padding: 8px 14px;
        font-size: 0.9rem;
    }
    
    .search-container button {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    .topic-card {
        padding: 0.8rem 1rem;
        min-height: 90px;
    }
    
    .topic-card h3 {
        font-size: 0.9rem;
    }
    
    .topic-card p {
        font-size: 0.7rem;
    }
    
    .chat-header {
        padding: 0.5rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .ai-avatar {
        width: 24px;
        height: 24px;
        font-size: 1.1rem;
    }
    
    .chat-history {
        min-height: 120px;
        max-height: 200px;
        padding: 0.5rem 0.4rem;
    }
    
    .chat-input-bar {
        padding: 0.5rem 0.6rem;
    }
    
    .chat-input-bar input[type="text"] {
        padding: 0.4em 0.6em;
        font-size: 0.8rem;
    }
    
    .send-btn {
        padding: 0.3em 0.7em;
        font-size: 0.8rem;
    }
}

/* Landscape Orientation Adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .search-section {
        margin: 1.5rem auto 2rem auto;
    }
    
    .recommended-topics {
        margin: 2rem auto 3rem auto;
    }
    
    .search-section h2,
    .recommended-topics h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .topic-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }
    
    .topic-card {
        min-height: 80px;
        padding: 0.8rem 1rem;
    }
    
    .ai-assistant-section.chat-app-card {
        min-height: 300px;
    }
    
    .chat-history {
        min-height: 120px;
        max-height: 180px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .search-container,
    .topic-card,
    .chat-header,
    .chat-input-bar {
        border-width: 0.5px;
    }
}

/* Print Styles */
@media print {
    .search-section,
    .recommended-topics {
        max-width: 100%;
        margin: 1rem 0;
    }
    
    .topic-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .ai-assistant-section.chat-app-card {
        display: none;
    }
    
    .search-container button,
    .send-btn {
        display: none;
    }
}
  