:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --highlight: #10b981;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    color: var(--text-primary);
    min-height: 100vh;
    background-attachment: fixed;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Hero Section */
.hero-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding-top: 40px;
    transition: all 0.5s ease-in-out;
}

.hero-section.searched {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
    min-height: auto;
    padding: 15px 20px 20px 120px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 2rem;
}

.logo {
    font-size: 5rem;
    font-weight: 800;
    margin-bottom: 2rem;
    text-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
    transition: all 0.3s ease;
}

.hero-section.searched .logo {
    font-size: 2rem;
    margin-bottom: 0;
}

.hero-section.searched .search-box {
    margin: 0;
    flex-grow: 1;
    max-width: 700px;
}

.hero-section.searched .search-tabs {
    width: 100%;
    justify-content: flex-start;
    margin-top: 10px;
    padding-left: 20px;
}

.hero-section.searched .fun-tags,
.hero-section.searched #surprise-wrapper {
    display: none;
}

.logo-accent {
    color: var(--accent);
}

.search-box {
    display: flex;
    width: 100%;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    padding: 8px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}

.hero-section:not(.searched) .search-tabs {
    display: none !important;
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
}

#main-search-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 1.2rem;
    font-family: 'Outfit', sans-serif;
    padding: 0 20px;
    outline: none;
}

#main-search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.glow-on-hover {
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 40px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.glow-on-hover:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 15px var(--accent);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    padding: 5px 15px;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    font-family: 'Outfit', sans-serif;
}

.tab-btn.active {
    color: var(--accent);
    border-bottom: 3px solid var(--accent);
}

.tab-btn:hover:not(.active) {
    color: white;
}

.fun-tags {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.tag {
    background: rgba(255,255,255,0.05);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(255,255,255,0.1);
}

.tag:hover {
    background: var(--accent);
    transform: translateY(-2px);
}

/* Results Content */
.content-section {
    animation: fadeIn 0.5s ease forwards;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

#back-home-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
}

#back-home-btn:hover {
    background: rgba(255,255,255,0.2);
}

.stats {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media(min-width: 800px) {
    .layout-grid {
        grid-template-columns: 1fr;
        gap: 3rem;
        align-items: start;
    }
    
    .layout-grid.has-panel {
        grid-template-columns: 1fr 350px; /* Main results wider, knowledge panel fixed width on right */
    }
}

/* Cards */
.result-card, .kp-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid rgba(255,255,255,0.05);
    transition: transform 0.2s ease;
}

.result-card:hover {
    transform: translateY(-5px);
    border-color: rgba(139, 92, 246, 0.3);
}

.result-title {
    color: #60a5fa;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 10px;
    display: inline-block;
}

.result-source {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.favicon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.result-body {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.result-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
}

.result-snippet {
    color: var(--text-secondary);
    line-height: 1.6;
    flex-grow: 1;
}

.searchmatch {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    padding: 0 4px;
    border-radius: 4px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 30px;
    padding-bottom: 20px;
}

.page-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.page-btn.active {
    background: var(--accent);
    font-weight: bold;
    box-shadow: 0 0 10px var(--accent);
}

.page-btn:hover:not(.active):not(:disabled) {
    background: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Knowledge Panel */
.kp-card {
    background: linear-gradient(145deg, var(--card-bg), rgba(139, 92, 246, 0.1));
    border: 2px solid rgba(139, 92, 246, 0.2);
}

.kp-image {
    width: 100%;
    max-height: 350px;
    object-fit: contain; /* ensures image is fully viewable without cropping */
    border-radius: 12px;
    margin-bottom: 1rem;
    background: rgba(0,0,0,0.1);
}

.kp-title {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.kp-extract {
    line-height: 1.6;
    color: var(--text-secondary);
}

.hidden {
    display: none !important;
}

/* Loader */
#loading {
    text-align: center;
    padding: 3rem;
}

.bouncing-loader {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.bouncing-loader > div {
    width: 16px;
    height: 16px;
    margin: 3px 6px;
    border-radius: 50%;
    background-color: var(--highlight);
    opacity: 1;
    animation: bouncing-loader 0.6s infinite alternate;
}

.bouncing-loader > div:nth-child(2) {
    animation-delay: 0.2s;
    background-color: var(--accent);
}

.bouncing-loader > div:nth-child(3) {
    animation-delay: 0.4s;
    background-color: #f59e0b;
}

@keyframes bouncing-loader {
    to {
        opacity: 0.1;
        transform: translateY(-16px);
    }
}

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

/* Settings Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.3s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

.modal-content {
    background: var(--bg-color);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 30px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    color: var(--text-primary);
}

body.light-mode .modal-content {
    background: white;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.setting-item label {
    font-weight: 600;
}

.setting-item select, .setting-item input[type="range"] {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 8px 12px;
    border-radius: 10px;
    outline: none;
}

body.light-mode .setting-item select {
    background: rgba(0,0,0,0.05);
    color: #1e293b;
    border: 1px solid rgba(0,0,0,0.1);
}

/* History Panel */
.search-box {
    position: relative;
}

.history-panel {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-color);
    border: 1px solid rgba(255,255,255,0.1);
    margin-top: 10px;
    border-radius: 20px;
    overflow: hidden;
    z-index: 50;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
}

body.light-mode .history-panel {
    background: white;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.history-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-primary);
}

.history-item:hover {
    background: rgba(255,255,255,0.05);
}

body.light-mode .history-item:hover {
    background: rgba(0,0,0,0.05);
}

/* Quest Card */
.quest-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 20px 30px;
    margin-top: 40px;
    max-width: 450px;
    text-align: center;
    backdrop-filter: blur(15px);
    transition: all 0.3s;
    animation: fadeIn 1s ease-out;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.hero-section.searched .quest-card {
    display: none;
}

.quest-header {
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent);
    margin-bottom: 8px;
}

.quest-body {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
}

.badge-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    padding: 8px 20px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 30px;
    color: #10b981;
    font-size: 0.95rem;
    font-weight: 700;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Notebook Stars */
.star-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    opacity: 0;
    backdrop-filter: blur(8px);
    z-index: 10;
}

.result-card:hover .star-btn {
    opacity: 1;
}

.star-btn.active {
    color: #fbbf24;
    opacity: 1;
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.4);
}

/* Background Themes */
body.bg-custom {
    background-size: cover !important;
    background-position: center !important;
    background-attachment: fixed !important;
    background-repeat: no-repeat !important;
}

/* Weather Effects */
#weather-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}
/* Autocomplete Panel */
.autocomplete-panel {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-color);
    border: 1px solid rgba(255,255,255,0.1);
    margin-top: 5px;
    border-radius: 20px;
    overflow: hidden;
    z-index: 60;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    backdrop-filter: blur(15px);
}

.autocomplete-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
    font-weight: 500;
}

.autocomplete-item:hover {
    background: rgba(255,255,255,0.05);
    padding-left: 25px;
}

/* Skeleton Loading */
.skeleton-card {
    height: 120px;
    background: linear-gradient(90deg, 
        rgba(255,255,255,0.03) 25%, 
        rgba(255,255,255,0.08) 50%, 
        rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 20px;
    margin-bottom: 20px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Infinite Scroll Loader */
#scroll-loader {
    padding: 40px;
    text-align: center;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
