/* Google-like Base Styles */
body {
    font-family: Arial, sans-serif; /* Common Google font */
    margin: 0;
    padding: 0;
    background-color: #fff; /* Pure white background */
    color: #222; /* Darker grey for text */
    -webkit-font-smoothing: antialiased; /* Smoother fonts */
    display: flex;
    flex-direction: column; /* Stacks main content and footer */
    min-height: 100vh;
}

/* --- Homepage Styles (index.php) --- */

/* This section contains ONLY the top-right link and does NOT affect main content centering */
.homepage-top-section {
    width: 100%;
    position: absolute; /* Position it absolutely relative to the body */
    top: 0;
    left: 0;
    padding: 20px; /* Provides space around the top-right link */
    box-sizing: border-box;
    z-index: 10; /* Ensure it's above other content if anything overlaps */
    display: flex;
    justify-content: flex-end; /* Push content to the right */
    align-items: flex-start; /* Align to the top of its available space */
}

.homepage-top-right {
    /* No absolute positioning here, it's handled by homepage-top-section */
    /* It just holds the link */
}

/* Ensure the main container for logo/search remains centered vertically and horizontally */
.homepage-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1; /* Takes up available vertical space */
    padding: 20px;
    box-sizing: border-box;
    margin: auto; /* This is key for robust vertical centering with flex-grow */
    /* Removed negative margin and calc() min-height */
}

.main-logo-area {
    text-align: center;
    margin-bottom: 30px;
}

.main-logo {
    max-width: 272px; /* Google logo width */
    height: 92px; /* Google logo height */
    object-fit: contain; /* Ensure aspect ratio is maintained */
    margin-bottom: 10px;
}

.site-name {
    font-size: 3em; /* Large site name */
    color: #4285f4; /* Google blue */
    margin: 0;
    font-weight: normal;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1); /* Subtle shadow for depth */
}

.main-search-form {
    width: 100%;
    max-width: 584px; /* Google search bar max width */
    text-align: center;
    margin-bottom: 20px;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid #dfe1e5; /* Light grey border */
    border-radius: 24px; /* Fully rounded corners */
    height: 44px; /* Standard search bar height */
    margin: 0 auto 20px; /* Center and space below */
    box-shadow: 0 2px 5px 1px rgba(64,60,67,.16); /* Subtle shadow for focus */
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input-wrapper:hover {
    box-shadow: 0 1px 6px 0 rgba(32,33,36,.28); /* Slightly more prominent shadow on hover */
}

.search-box {
    flex-grow: 1; /* Takes up available space */
    padding: 0 14px;
    height: 100%;
    border: none;
    outline: none;
    font-size: 1.1em;
    background: transparent; /* No background */
    color: #222;
}

.search-buttons {
    display: flex;
    justify-content: center;
    gap: 15px; /* Space between buttons */
}

.search-button {
    background-color: #f8f9fa; /* Light grey button */
    border: 1px solid #f8f9fa;
    border-radius: 4px;
    color: #3c4043; /* Dark grey text */
    font-family: Arial, sans-serif;
    font-size: 14px;
    height: 36px;
    min-width: 54px;
    padding: 0 16px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.search-button:hover {
    background-color: #f1f1f1;
    border: 1px solid #dadce0;
    box-shadow: 0 1px 1px rgba(0,0,0,.1);
}

.footer {
    width: 100%;
    text-align: center;
    padding: 20px;
    color: #70757a;
    font-size: 0.9em;
    box-sizing: border-box;
    margin-top: auto; /* Push footer to bottom */
}


/* --- Results Page Styles (search.php) --- */
.results-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Distribute items to edges */
    padding: 10px 20px;
    border-bottom: 1px solid #ebebeb; /* Light grey border */
    background-color: #fff;
    position: sticky; /* Keep header at top on scroll */
    top: 0;
    z-index: 1000;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); /* Subtle shadow for depth */
}

.header-left {
    display: flex;
    align-items: center;
    flex-grow: 1; /* Allow left side to grow */
}

.small-logo-link {
    margin-right: 20px;
    display: flex;
    align-items: center;
}

.small-logo {
    height: 30px; /* Smaller logo for results page */
    width: auto;
    object-fit: contain;
}

.top-search-form {
    display: flex;
    flex-grow: 1; /* Takes up remaining space */
    max-width: 600px; /* Limit width */
    margin-right: 20px; /* Space for other elements if added later */
}

.search-input-wrapper-top {
    display: flex;
    align-items: center;
    border: 1px solid #dfe1e5;
    border-radius: 24px;
    height: 40px; /* Slightly smaller than homepage */
    flex-grow: 1;
    box-shadow: 0 2px 5px 1px rgba(64,60,67,.16); /* Subtle shadow for focus */
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input-wrapper-top:hover {
    box-shadow: 0 1px 6px 0 rgba(32,33,36,.28);
}


.search-box-top {
    flex-grow: 1;
    padding: 0 14px;
    height: 100%;
    border: none;
    outline: none;
    font-size: 1em;
    background: transparent;
    color: #222;
}

.search-button-top {
    background-color: #4285f4; /* Google blue search button */
    border: none;
    border-radius: 24px; /* Rounded button */
    color: white;
    font-size: 1em;
    padding: 0 18px;
    margin-left: 10px; /* Space from search box */
    cursor: pointer;
    transition: background-color 0.2s;
    height: 40px; /* Match height of search input */
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-button-top:hover {
    background-color: #357ae8; /* Darker blue on hover */
}

.results-container {
    max-width: 650px; /* Standard content width */
    margin: 20px auto; /* Center content */
    padding: 0 20px; /* Padding on sides */
}

.search-stats {
    font-size: 0.9em;
    color: #70757a; /* Grey text */
    margin-bottom: 25px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.search-result-item {
    margin-bottom: 20px;
}

.result-title {
    font-size: 1.2em;
    color: #1a0dab; /* Google blue link */
    text-decoration: none;
    display: block; /* Make it a block element for spacing */
    margin-bottom: 3px;
}

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

.result-url {
    font-size: 0.9em;
    color: #006621; /* Green URL */
    margin-bottom: 5px;
    word-break: break-all; /* Prevents long URLs from overflowing */
}

.result-description {
    font-size: 0.95em;
    color: #4d5156; /* Dark grey description text */
    line-height: 1.5;
}

.disclaimer {
    font-style: italic;
    color: #70757a;
    margin-top: 50px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    text-align: center;
    font-size: 0.9em;
}

/* Pagination Styles (Google-like) */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 40px;
    margin-bottom: 40px;
    font-size: 0.9em;
}

.pagination-link, .pagination-current {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    margin: 0 5px;
    border-radius: 50%; /* Circle for numbers */
    text-decoration: none;
    color: #1a0dab; /* Blue links */
}

.pagination-current {
    background-color: #f1f1f1; /* Light grey for current page */
    font-weight: bold;
    color: #222;
}

.pagination-link:hover {
    background-color: #f1f1f1;
}

.pagination-ellipsis {
    color: #70757a;
    margin: 0 5px;
}

/* --- Account Link Styles (Refined for Google-like appearance) --- */

/* Default account link style (used for search page 'Sign In' and both page 'Logout') */
.account-link {
    font-size: 0.85em; /* Slightly smaller font */
    color: #1a0dab; /* Google blue link color */
    text-decoration: none;
    padding: 8px 15px;
    border: 1px solid transparent; /* Default transparent border */
    border-radius: 4px;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
    white-space: nowrap; /* Prevent wrapping */
}

.account-link:hover {
    background-color: #f1f1f1;
    border-color: #dadce0;
    box-shadow: 0 1px 1px rgba(0,0,0,.1);
}

/* Style for the "Sign In" button specifically on the HOMEPAGE (Google's filled blue button) */
.homepage-account-button {
    background-color: #1a73e8; /* Google blue */
    color: white; /* White text */
    border: 1px solid #1a73e8; /* Blue border */
    padding: 8px 16px; /* Slightly different padding */
    border-radius: 4px; /* Slightly rounded */
    font-weight: 500; /* Medium weight font */
}

.homepage-account-button:hover {
    background-color: #1a73e8; /* Keep background blue on hover */
    border-color: #1a73e8; /* Keep border blue on hover */
    box-shadow: 0 1px 2px rgba(60,64,67,.3); /* More subtle shadow */
    opacity: 0.9; /* Slight opacity change for hover effect */
}


/* Welcome message styling */
.welcome-message {
    font-size: 0.9em;
    color: #5f6368; /* A neutral grey */
    margin-right: 15px; /* Space between message and logout button */
    white-space: nowrap; /* Prevent wrapping on multiple lines */
}

/* Basic styling for auth forms (login.php, register.php) */
.auth-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 30px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}
.auth-container h2 {
    color: #4285f4;
    margin-bottom: 20px;
}
.auth-container input[type="text"],
.auth-container input[type="password"] {
    width: calc(100% - 22px);
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
}
.auth-container button {
    background-color: #4285f4;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s;
}
.auth-container button:hover {
    background-color: #357ae8;
}
.auth-message {
    margin-top: 20px;
    font-weight: bold;
    color: green;
}
.auth-message.error {
    color: red;
}


/* --- Media Queries for Responsiveness (Mobile Adaptation) --- */
@media (max-width: 768px) {
    /* Homepage */
    .homepage-top-section {
        position: static; /* Remove absolute positioning on mobile */
        min-height: auto;
        padding: 10px 0;
        border-bottom: 1px solid #eee;
        display: flex;
        justify-content: center;
        align-items: center; /* Center vertically if space allows */
    }

    .homepage-top-right {
        position: static; /* Ensure it behaves normally within flex container */
        text-align: center;
        width: 100%; /* Take full width for centering content */
        top: auto;
        right: auto;
        padding: 0;
    }

    .homepage-container {
        padding-top: 10px;
        margin-top: 0;
        min-height: auto;
    }

    .main-logo {
        max-width: 200px;
        height: auto;
    }
    .site-name {
        font-size: 2.2em;
    }
    .main-search-form {
        max-width: 90%;
    }
    .search-input-wrapper {
        box-shadow: none;
        border: 1px solid #dfe1e5;
    }
    .search-input-wrapper:hover {
        box-shadow: none;
    }
    .search-buttons {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    .search-button {
        width: 90%;
        margin: 0 auto;
    }
    .homepage-account-button {
        width: auto;
        display: inline-block;
        padding: 8px 12px;
        font-size: 0.85em;
    }
    .footer {
        padding: 10px;
        font-size: 0.8em;
    }

    /* Results Page */
    .results-page-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px;
    }

    .header-left {
        flex-direction: column;
        width: 100%;
        margin-bottom: 10px;
        align-items: flex-start;
    }

    .small-logo-link {
        margin-right: 0;
        margin-bottom: 10px;
    }

    .top-search-form {
        width: 100%;
        max-width: none;
        margin-right: 0;
    }

    .search-input-wrapper-top {
        box-shadow: none;
        border: 1px solid #dfe1e5;
    }
    .search-input-wrapper-top:hover {
        box-shadow: none;
    }
    .search-button-top {
        margin-left: 5px;
        padding: 0 14px;
        font-size: 0.9em;
    }

    .header-right {
        width: 100%;
        justify-content: center;
        margin-left: 0;
        margin-top: 10px;
    }

    .account-link {
        width: auto;
        padding: 8px 12px;
        font-size: 0.85em;
    }

    .welcome-message {
        margin-right: 0;
        margin-bottom: 10px;
        display: block;
        text-align: center;
    }

    .results-container {
        margin: 15px auto;
        padding: 0 15px;
    }
    .result-title {
        font-size: 1.1em;
    }
    .result-url, .result-description {
        font-size: 0.85em;
    }
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
    }
}