/* LOOGI Theme - Google Clone Style */

/* GLOBAL RESET - Fixes width/padding issues */
*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    /* Light Mode Default Variables */
    --color-bg: #ffffff;
    --color-text: #202124;
    --color-text-light: #5f6368;
    --color-link: #1a0dab;
    --color-link-visited: #609;
    --color-url: #202124;
    --color-border: #dfe1e5;
    --color-hover: #f1f3f4;
    --color-panel: #ffffff;
    --color-input-bg: #ffffff;
    --color-shadow: rgba(32,33,36,.28);
    --color-shadow-hover: rgba(32,33,36,.28);
    --color-footer-bg: #f2f2f2;
    --color-footer-text: #70757a;
    --color-btn-bg: #f8f9fa;
    --color-btn-text: #3c4043;
    --color-btn-border: #f8f9fa;
    --color-btn-hover: #f8f9fa;
    
    --color-blue: #4285f4;
    --color-red: #ea4335;
    --color-yellow: #fbbc05;
    --color-green: #34a853;
    
    --font-family: arial, sans-serif;
}

/* Dark Mode Overrides (Media Query & Class) */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #202124;
        --color-text: #e8eaed;
        --color-text-light: #9aa0a6;
        --color-link: #8ab4f8;
        --color-link-visited: #c58af9;
        --color-url: #e8eaed;
        --color-border: #3c4043;
        --color-hover: #303134;
        --color-panel: #303134;
        --color-input-bg: #202124; /* Google search box is darker/transparent */
        --color-shadow: rgba(0,0,0,.5);
        --color-shadow-hover: rgba(0,0,0,.7);
        --color-footer-bg: #171717;
        --color-footer-text: #9aa0a6;
        --color-btn-bg: #303134;
        --color-btn-text: #e8eaed;
        --color-btn-border: #303134;
        --color-btn-hover: #3c4043;
    }
}

/* Force Light Class */
:root.light-theme {
    --color-bg: #ffffff;
    --color-text: #202124;
    --color-text-light: #5f6368;
    --color-link: #1a0dab;
    --color-link-visited: #609;
    --color-url: #202124;
    --color-border: #dfe1e5;
    --color-hover: #f1f3f4;
    --color-panel: #ffffff;
    --color-input-bg: #ffffff;
    --color-shadow: rgba(32,33,36,.28);
    --color-footer-bg: #f2f2f2;
    --color-footer-text: #70757a;
    --color-btn-bg: #f8f9fa;
    --color-btn-text: #3c4043;
    --color-btn-border: #f8f9fa;
}

/* Force Dark Class */
:root.dark-theme {
    --color-bg: #202124;
    --color-text: #e8eaed;
    --color-text-light: #9aa0a6;
    --color-link: #8ab4f8;
    --color-link-visited: #c58af9;
    --color-url: #e8eaed;
    --color-border: #5f6368;
    --color-hover: #303134;
    --color-panel: #303134;
    --color-input-bg: #202124;
    --color-shadow: rgba(0,0,0,.5);
    --color-footer-bg: #171717;
    --color-footer-text: #9aa0a6;
    --color-btn-bg: #303134;
    --color-btn-text: #e8eaed;
    --color-btn-border: #303134;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    font-size: 14px;
    line-height: 1.58;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--color-text); /* Default for nav links */
    text-decoration: none;
    cursor: pointer;
}

a:hover {
    text-decoration: underline;
}

/* Base Layout */
.main-content {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Index Page */
.index-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100%;
}

.logo-large {
    font-family: 'Product Sans', Arial, sans-serif;
    font-size: 90px;
    font-weight: bold;
    letter-spacing: -2px;
    margin-bottom: 20px;
    user-select: none;
}

.logo-l { color: var(--color-blue); }
.logo-o1 { color: var(--color-red); }
.logo-o2 { color: var(--color-yellow); }
.logo-g { color: var(--color-blue); }
.logo-i { color: var(--color-green); }

.search-box-wrapper {
    width: 100%;
    max-width: 584px;
    position: relative;
    margin-bottom: 20px;
}

.search-form-index {
    display: flex;
    width: 100%;
}

.search-input-group {
    display: flex;
    align-items: center;
    width: 100%;
    background: var(--color-input-bg);
    border: 1px solid var(--color-border);
    box-shadow: none;
    border-radius: 24px;
    height: 44px;
    padding: 5px 8px 0 14px;
    transition: box-shadow 200ms cubic-bezier(0.4, 0.0, 0.2, 1), background-color 0.3s;
}

.search-input-group:hover, .search-input-group:focus-within {
    box-shadow: 0 1px 6px var(--color-shadow);
    border-color: rgba(223,225,229,0);
    background: var(--color-panel);
}

.search-icon-wrapper {
    color: #9aa0a6;
    padding-right: 13px;
    display: flex;
    align-items: center;
}

.search-icon-wrapper svg {
    fill: #9aa0a6;
}

.search-input-index {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    color: var(--color-text);
    height: 34px;
    line-height: 34px;
}

.index-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 18px;
}

.btn-light {
    background-color: var(--color-btn-bg);
    border: 1px solid var(--color-btn-border);
    border-radius: 4px;
    color: var(--color-btn-text);
    font-family: arial, sans-serif;
    font-size: 14px;
    margin: 11px 4px;
    padding: 0 16px;
    line-height: 27px;
    height: 36px;
    min-width: 54px;
    text-align: center;
    cursor: pointer;
    user-select: none;
}

.btn-light:hover {
    box-shadow: 0 1px 1px rgba(0,0,0,.1);
    background-color: var(--color-btn-hover);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    text-decoration: none;
}

/* Footer */
.footer {
    background: var(--color-footer-bg);
    color: var(--color-footer-text);
    font-size: 14px;
    flex-shrink: 0;
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
    border-top: 1px solid var(--color-border);
}

.footer-top {
    padding: 15px 30px;
    border-bottom: 1px solid var(--color-border);
}

.footer-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 0 20px;
}

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

.footer-link-item {
    display: block;
    padding: 15px 15px;
    white-space: nowrap;
}

.footer a {
    color: var(--color-footer-text);
    text-decoration: none;
}

.footer a:hover {
    color: var(--color-text);
    text-decoration: underline;
}

/* Results Page */
.results-header {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: 20px 20px 0 20px;
    display: flex;
    flex-direction: column;
}

.header-top {
    display: flex;
    align-items: center;
    width: 100%;
    padding-bottom: 15px;
}

.header-logo-area {
    padding-right: 30px;
    display: flex;
    align-items: center;
}

.logo-small {
    font-family: 'Product Sans', Arial, sans-serif;
    font-size: 24px;
    font-weight: bold;
    letter-spacing: -1px;
    text-decoration: none !important;
}

.search-box-results {
    flex: 0 1 692px;
    position: relative;
}

.search-input-results-group {
    display: flex;
    align-items: center;
    background: var(--color-input-bg);
    border: 1px solid transparent;
    box-shadow: 0 2px 5px 1px var(--color-shadow);
    border-radius: 24px;
    height: 44px;
    width: 100%;
}

.search-input-results-group:hover, .search-input-results-group:focus-within {
    box-shadow: 0 2px 8px 1px var(--color-shadow-hover);
    background: var(--color-panel);
}

.search-input-results {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    color: var(--color-text);
    height: 40px;
    padding: 0 20px;
    border-radius: 24px;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 20px;
    margin-left: 100px;
    font-size: 14px;
    color: var(--color-text-light);
    height: 40px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0 5px;
    cursor: pointer;
    color: var(--color-text-light);
    position: relative;
    height: 100%;
    text-decoration: none !important;
}

.nav-item.active {
    color: var(--color-blue);
    border-bottom: 3px solid var(--color-blue);
}

.nav-item:hover {
    color: var(--color-blue);
}

/* Results Content */
.results-wrapper {
    margin-left: 120px;
    max-width: 652px;
    padding-top: 20px;
    padding-bottom: 40px;
}

.result-item-google {
    margin-bottom: 25px;
    font-family: arial, sans-serif;
}

.result-cite {
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.3;
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-bottom: 5px;
}

.result-favicon-small {
    width: 16px;
    height: 16px;
    margin-right: 12px;
    border-radius: 50%;
    background-color: var(--color-hover);
}

.result-site-name {
    color: var(--color-text);
    font-weight: normal;
}

.result-title-google {
    display: block;
    font-size: 20px;
    line-height: 1.3;
    color: var(--color-link);
    font-weight: normal;
    padding-top: 5px;
    margin-bottom: 3px;
    text-decoration: none;
}

.result-title-google:hover {
    text-decoration: underline;
}

.result-title-google:visited {
    color: var(--color-link-visited);
}

.result-snippet-google {
    color: var(--color-text-light);
    line-height: 1.58;
    font-size: 14px;
}

.result-snippet-google em {
    font-weight: bold;
    color: var(--color-text);
    font-style: normal;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    color: var(--color-text);
    transition: background-color 0.3s;
    z-index: 1000;
}

.theme-toggle-btn:hover {
    background-color: var(--color-hover);
}

.theme-toggle-btn svg {
    fill: currentColor;
    width: 24px;
    height: 24px;
}

/* Modal / Popup Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-card {
    background-color: var(--color-panel);
    color: var(--color-text);
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    padding: 30px;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    border: 1px solid var(--color-border);
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 15px;
}

.modal-title {
    font-size: 20px;
    font-weight: bold;
    color: var(--color-text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--color-text-light);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--color-text);
}

.modal-body {
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text);
}

.modal-body p {
    margin-bottom: 15px;
}

.modal-footer {
    margin-top: 25px;
    text-align: right;
}

.btn-modal {
    background-color: var(--color-blue);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.btn-modal:hover {
    background-color: #3367d6;
}

/* =========================================
   MOBILE OPTIMIZATIONS (Max Width 768px)
   ========================================= */
@media (max-width: 768px) {
    /* Global & Typography */
    body {
        overflow-x: hidden;
        width: 100%;
        -webkit-tap-highlight-color: transparent;
        background-color: var(--color-bg);
    }

    /* INDEX PAGE MOBILE */
    .index-container {
        padding: 0 20px;
        justify-content: center;
        height: 100dvh; /* Force viewport height */
        width: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden; /* Cut off anything that overflows */
        position: relative;
    }

    .logo-large {
        font-size: 60px; /* Slightly smaller to ensure fit on small phones */
        margin-bottom: 20px;
        flex-shrink: 0;
    }

    .search-box-wrapper {
        width: 100%;
        box-shadow: 0 2px 8px 1px rgba(0,0,0,0.15);
        border-radius: 30px;
        margin-bottom: 15px;
        background: var(--color-input-bg);
        flex-shrink: 0;
    }

    .search-input-group {
        height: 50px;
        border: 1px solid var(--color-border);
        border-radius: 25px;
        padding: 0 15px;
        background: transparent;
        box-shadow: none;
    }
    
    .index-buttons {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 12px;
        margin-top: 10px;
        align-items: center;
        flex-shrink: 0;
    }
    
    .btn-light {
        width: 100%;
        max-width: 300px;
        height: 48px;
        border-radius: 24px;
        background-color: var(--color-panel);
        border: 1px solid var(--color-border);
        font-size: 15px;
        margin: 0;
        color: var(--color-text);
    }

    /* FOOTER MOBILE - FIXED POSITION */
    .footer {
        position: fixed; /* Pinned to bottom viewport */
        bottom: 0;
        left: 0;
        width: 100%;
        border-top: none;
        background: var(--color-bg); /* Opaque background so content doesn't bleed through */
        padding-bottom: 15px; /* Safe area padding */
        z-index: 50; /* Above content */
    }

    .footer-bottom {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 10px;
        gap: 15px;
        text-align: center;
    }
    
    .footer-links {
        justify-content: center;
        gap: 15px;
    }

    .footer-link-item {
        font-size: 12px;
        color: var(--color-text-light);
    }

    /* RESULTS HEADER */
    .results-header {
        padding: 8px 12px;
        background-color: var(--color-bg);
        position: sticky;
        top: 0;
        z-index: 1000;
        border-bottom: 1px solid var(--color-border);
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
        display: flex;
        align-items: center;
        gap: 12px;
        height: 64px;
        box-sizing: border-box;
    }

    .header-top {
        flex-direction: row;
        width: 100%;
        padding: 0;
        gap: 12px;
        align-items: center;
    }

    .header-logo-area {
        padding: 0;
        flex-shrink: 0;
    }

    .logo-small {
        font-size: 28px;
        letter-spacing: -1px;
    }

    .search-box-results {
        flex: 1;
        width: auto;
    }

    .search-input-results-group {
        height: 44px;
        background: var(--color-hover);
        border-radius: 22px;
        border: none;
        box-shadow: none;
        padding: 0 15px;
        display: flex;
        align-items: center;
    }

    .search-input-results {
        padding: 0 10px;
        font-size: 16px;
        height: 100%;
        color: var(--color-text);
    }
    
    .search-icon-wrapper {
        padding: 0;
        display: flex;
    }

    .header-tools {
        display: none;
    }

    .nav-tabs {
        display: none;
    }

    /* RESULTS LIST */
    .results-wrapper {
        margin: 0;
        padding: 0;
        width: 100%;
    }

    .result-item-google {
        margin: 0;
        padding: 16px;
        border-bottom: 1px solid var(--color-border); /* Subtle separator */
        background: var(--color-bg);
    }
    
    .result-cite {
        display: flex;
        align-items: center;
        margin-bottom: 6px;
        font-size: 12px;
        color: var(--color-text);
    }

    .result-favicon-small {
        width: 18px;
        height: 18px;
        margin-right: 12px;
        border-radius: 50%;
        background-color: var(--color-panel);
    }
    
    .result-site-name {
        font-weight: 500;
        color: var(--color-text);
        font-size: 12px;
        margin-bottom: 2px;
    }

    .result-title-google {
        font-size: 18px;
        line-height: 1.3;
        color: var(--color-blue);
        margin-bottom: 6px;
        padding: 0;
        font-weight: 400;
        letter-spacing: 0;
        display: block;
    }

    .result-snippet-google {
        font-size: 14px;
        line-height: 1.5;
        color: var(--color-text-light);
        display: -webkit-box;
        -webkit-line-clamp: 4;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Pagination */
    .pagination {
        padding: 20px 0 60px 0;
    }
    
    .nav-links {
        gap: 15px;
    }

    /* Hide Theme Toggle on Mobile to prevent overlap */
    .theme-toggle-btn {
        display: none;
    }

    /* Modal Mobile */
    .modal-card {
        width: 100%;
        height: 100%;
        max-width: 100%;
        border-radius: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        border: none;
    }
    
    .modal-body {
        flex: 1;
        overflow-y: auto;
    }
}

/* Modal / Popup Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-card {
    background-color: var(--color-panel);
    color: var(--color-text);
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    padding: 30px;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    border: 1px solid var(--color-border);
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 15px;
}

.modal-title {
    font-size: 20px;
    font-weight: bold;
    color: var(--color-text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--color-text-light);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--color-text);
}

.modal-body {
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text);
}

.modal-body p {
    margin-bottom: 15px;
}

.modal-footer {
    margin-top: 25px;
    text-align: right;
}

.btn-modal {
    background-color: var(--color-blue);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.btn-modal:hover {
    background-color: #3367d6;
}