/**
 * ============================================
 * 💻 Global & Reset Styles
 * ============================================
 */

/* Box-Sizing Reset */
html {
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

/* Base Document Setup */
html,
body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    /* Prevent horizontal scrolling on the root level */
    overflow-x: clip;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}


/**
 * ============================================
 * 🎨 Body & Background
 * ============================================
 */

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #ffffff;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    padding-bottom: 20px;
    background: linear-gradient(135deg, #ff00e0, #ff6a00, #00c3ff, #7b2fff);
    background-size: 400% 400%;
    animation: bgGradient 40s ease infinite;
}

@keyframes bgGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}


/**
 * ============================================
 * 🏗️ Main Layout & Header
 * ============================================
 */

main {
    flex: 1;
    width: 100%;
    /* FIX: Removed min-width: 1000px to prevent mobile cutoff */
    min-width: 0; 
    margin: 0 auto;
    padding: 0 15px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.page-header {
    text-align: center;
    margin: 20px auto;
    width: 100%;
    padding: 0 10px;
}

/* Fluid Typography for Title */
.page-header h1 {
    font-size: clamp(1.5rem, 6vw, 2.2rem); 
    font-weight: 800;
    margin: 0;
    line-height: 1.2;
    color: #ffffff !important;
}

.page-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 8px 0 0 0;
    color: #ffffff;
}

.page-header h3 {
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 5px 0 0 0;
    color: #f0f0f0;
}


/**
 * ============================================
 * 💬 Chat & Input Elements
 * ============================================
 */

#chat-input,
#searchInput {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.32);
    color: #ffffff;
    border-radius: 14px;
    padding: 12px 15px;
    width: 100%;
    font-size: 1rem;
    transition: all 0.25s ease;
    min-height: 50px;
    height: 50px;
    -webkit-appearance: none;
}

#chat-input::placeholder,
#searchInput::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

#chat-input:focus,
#searchInput:focus {
    border-color: #ffffff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.2);
}

#chat-send {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 14px;
    padding: 0 20px;
    font-weight: 700;
    cursor: pointer;
    min-height: 50px;
    height: 50px;
    touch-action: manipulation;
    white-space: nowrap;
}

#chat-log {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 500px; 
    max-height: 600px;
    gap: 10px;
    padding: 10px; /* Reduced for mobile */
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 16px;
    margin: 10px;
    overflow-y: auto;
    color: #ffffff;
    -webkit-overflow-scrolling: touch;
}

/* Individual Card - Mobile Responsive */
.trend-card {
    flex: 0 0 auto;           
    width: 85%;              
    max-width: 100%;        
    padding: 5px;  
    box-sizing: border-box;    
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 255, 157, 0.2);
    border-radius: 1rem;
    display: flex;
    overflow-x: auto;
    flex-direction: column;
}

/* Desktop sizing for cards */
@media (min-width: 1024px) {
    .trend-card {
        flex: 0 0 auto;
        width: auto;
    }
}

.trend-card-row {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 0px 5px;         /* prevents left edge cutoff */
    scroll-padding-left: 5px;  /* helps snap alignment */
    width: 100%;
    -webkit-overflow-scrolling: touch;
}
.trend-card:hover {
    transform: translateY(-5px);
    border-color: #00ff9d;
}

.trend-card img {
    width: 100%;
    aspect-ratio: 16/9;
    height: auto;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.score-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #10b981;
    color: white;
    font-weight: 800;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 6px;
    z-index: 20;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.trend-title a {
    color: #ffffff;
    font-weight: 700;
    text-decoration: none;
    font-size: 1rem;
    display: block;
    margin-bottom: 8px;
    word-wrap: break-word;
}

.trend-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.trend-btn {
    font-size: 0.75rem;
    border-radius: 20px;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.2);
    color: #ffffff;
    cursor: pointer;
    flex-grow: 1;
}
.trend-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}


/**
 * ============================================
 * ✍️ Manual Trend Section
 * ============================================
 */

#manual-trends-section {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    height: auto;
    padding: 15px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
    box-sizing: border-box;
}

#manual-trends-section .trend-card {
    width: 100%;
    max-width: 100%;
}

@media (min-width: 768px) {
    #manual-trends-section {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        max-height: 650px;
        overflow-y: auto;
        align-items: flex-start;
    }
    #manual-trends-section .trend-card {
        width: 240px;
        flex: 0 0 auto;
    }
}


/**
 * ============================================
 * ⬇️ Bottom Buttons
 * ============================================
 */

.bottom-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    /* FIX: Changed fixed 1200px to 100% responsive width */
    width: 100%; 
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 10px;
    box-sizing: border-box;
}

.bottom-buttons a,
.bottom-buttons button {
    flex: 1 1 100%; /* Full width on phones */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border-radius: 12px;
    padding: 15px;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    min-height: 80px;
}

@media (min-width: 600px) {
    .bottom-buttons a,
    .bottom-buttons button {
        flex: 1 1 45%; /* Two-column on tablets/desktop */
    }
}

/* Gradient Button */
.semi-transparent-gradient {
    display: flex;
    width: 160px;
    max-width: 100%;
    margin: 10px auto; 
    height: 50px;
    background: linear-gradient(35deg, rgba(255,255,255,0.1), rgba(0,123,255,0.1), rgba(255,0,0,0.1));
    background-size: 200% 200%;
    animation: gradientMove 3s ease infinite;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    text-align: center;
    text-decoration: none;
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 12px;
}

@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}


/**
 * ============================================
 * 🔍 Search Dropdown
 * ============================================
 */

#searchResults {
    background: #ffffff !important;
    border-radius: 12px;
    padding: 0;
    list-style: none;
    position: absolute;
    z-index: 999;
    max-height: 250px;
    overflow-y: auto;
    width: 90%; /* Responsive width */
    max-width: 600px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

#searchResults li {
    padding: 12px 15px;
    border-bottom: 1px solid #eeeeee;
    color: #000000 !important;
}


/**
 * ============================================
 * 🖼️ Modals
 * ============================================
 */

.custom-modal,
#ai-modal,
#app-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 10px;
}

.custom-modal-content,
#ai-modal-content {
    background: #0f172a;
    padding: 20px;
    width: 100%;
    max-width: 700px;
    border-radius: 16px;
    border: 1px solid #38bdf8;
    color: #ffffff;
    max-height: 90vh;
    overflow-y: auto;
}


/**
 * ============================================
 * 🧮 Calculator Specifics
 * ============================================
 */

.calc-inputs,
.money-calc-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.calc-inputs input,
.money-calc-inputs input,
.money-calc-inputs select {
    background: #1b222c;
    color: #ffffff;
    border: 1px solid #00e0ff;
    border-radius: 6px;
    padding: 12px;
    flex: 1 1 100%;
}

@media (min-width: 480px) {
    .calc-inputs input,
    .money-calc-inputs input {
        flex: 1 1 45%;
    }
}


/**
 * ============================================
 * ✨ Animations & Utilities
 * ============================================
 */

.glass {
    background: rgba(255, 255, 255, 0.12);
    border: 1.5px solid rgba(255, 255, 255, 0.28);
    border-radius: 18px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.25);
    color: white;
}

.white-border-box {
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 10px;
    box-sizing: border-box;
    padding: 20px;
}
/* Center More Tools dropdown */
.trend-card .hidden {
    margin: 0 auto;
    justify-content: center;
}

.trend-card .trend-btn {
    text-align: center;
}