:root {
    --primary-color: #6c5ce7;
    --primary-hover: #5b4cc4;
    --text-color: #202124;
    --secondary-text: #5f6368;
    --bg-color: #ffffff;
    --header-bg: #ffffff;
    --footer-bg: #f2f2f2;
    --footer-text: #70757a;
    --border-color: #dfe1e5;
    --hover-bg: #f8f9fa;
    --link-color: #1a0dab;
    --url-color: #202124;
    --shadow-sm: 0 1px 6px rgba(32, 33, 36, .28);
    --radius-md: 8px;
    --radius-lg: 24px;
    --menu-bg: #ffffff;
    --menu-hover: #f1f3f4;
    --menu-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    --input-bg: #ffffff;
    --input-border: #dfe1e5;
    --danger-color: #ea4335;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #8c7ae6;
        --primary-hover: #a29bfe;
        --text-color: #bdc1c6;
        --secondary-text: #9aa0a6;
        --bg-color: #202124;
        --header-bg: #303134;
        --footer-bg: #171717;
        --footer-text: #9aa0a6;
        --border-color: #3c4043;
        --hover-bg: #303134;
        --link-color: #8ab4f8;
        --url-color: #bdc1c6;
        --shadow-sm: 0 1px 6px rgba(0, 0, 0, 0.5);
        --menu-bg: #303134;
        --menu-hover: #3c4043;
        --menu-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
        --input-bg: #303134;
        --input-border: #5f6368;
    }
}

/* Manual Theme Overrides */
body.light-theme {
    --primary-color: #6c5ce7;
    --primary-hover: #5b4cc4;
    --text-color: #202124;
    --secondary-text: #5f6368;
    --bg-color: #ffffff;
    --header-bg: #ffffff;
    --footer-bg: #f2f2f2;
    --footer-text: #70757a;
    --border-color: #dfe1e5;
    --hover-bg: #f8f9fa;
    --link-color: #1a0dab;
    --url-color: #202124;
    --shadow-sm: 0 1px 6px rgba(32, 33, 36, .28);
    --menu-bg: #ffffff;
    --menu-hover: #f1f3f4;
    --menu-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    --input-bg: #ffffff;
    --input-border: #dfe1e5;
}

body.dark-theme {
    --primary-color: #8c7ae6;
    --primary-hover: #a29bfe;
    --text-color: #bdc1c6;
    --secondary-text: #9aa0a6;
    --bg-color: #202124;
    --header-bg: #303134;
    --footer-bg: #171717;
    --footer-text: #9aa0a6;
    --border-color: #3c4043;
    --hover-bg: #303134;
    --link-color: #8ab4f8;
    --url-color: #bdc1c6;
    --shadow-sm: 0 1px 6px rgba(0, 0, 0, 0.5);
    --menu-bg: #303134;
    --menu-hover: #3c4043;
    --menu-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    --input-bg: #303134;
    --input-border: #5f6368;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    color: var(--text-color);
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

input,
button,
select,
textarea {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

::placeholder {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Common Components */
a {
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
}

/* Header & User Panel */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.results-page .main-header {
    position: static;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 30px 0 30px;
    /* Reduced bottom padding for tabs */
    flex-wrap: wrap;
}

.user-panel {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--secondary-text);
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background-color: rgba(128, 128, 128, 0.1);
    color: var(--text-color);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a29bfe, #6c5ce7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

/* Theme Menu & User Menu */
.theme-menu-container,
.user-profile-container {
    position: relative;
}

.theme-dropdown,
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    /* RTL adjusted */
    margin-top: 10px;
    background-color: var(--menu-bg);
    border-radius: 8px;
    box-shadow: var(--menu-shadow);
    width: 150px;
    padding: 8px 0;
    display: none;
    z-index: 100;
    border: 1px solid var(--border-color);
}

.dropdown-menu.user-menu {
    width: 250px;
    padding: 0;
}

/* Fix for RTL positioning - Removed as user panel is now on left side */

.theme-dropdown.show,
.dropdown-menu.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

.theme-option,
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--text-color);
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.theme-option:hover,
.dropdown-item:hover {
    background-color: var(--menu-hover);
}

.theme-option.active {
    color: var(--primary-color);
    font-weight: bold;
    background-color: var(--menu-hover);
}

.theme-option svg,
.dropdown-item svg {
    width: 16px;
    height: 16px;
}

/* User Menu Specifics */
.user-info-header {
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--hover-bg);
    border-bottom: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
}

.user-avatar-small {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a29bfe, #6c5ce7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: bold;
    color: var(--text-color);
}

.user-email {
    font-size: 12px;
    color: var(--secondary-text);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 4px 0;
    border: none;
}

.text-danger {
    color: var(--danger-color);
}

.text-danger:hover {
    background-color: rgba(234, 67, 53, 0.1);
}

/* Search Components */
.search-container {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 584px;
    margin: 0 auto;
    position: relative;
}

.search-bar {
    width: 100%;
    height: 46px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    padding: 0 45px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
}

.search-bar:hover,
.search-bar:focus {
    box-shadow: var(--shadow-sm);
    border-color: rgba(223, 225, 229, 0);
    background-color: var(--bg-color);
}

.search-icon-wrapper {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary-text);
}

/* Tabs Navigation */
.tabs-container {
    width: 100%;
    margin-top: 15px;
    display: flex;
    gap: 20px;
    max-width: 690px;
    margin-right: 150px;
    /* Align with results */
}

@media (max-width: 992px) {
    .tabs-container {
        margin-right: 0;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 5px;
    }
}

.tab-link {
    color: var(--secondary-text);
    padding-bottom: 12px;
    font-size: 14px;
    border-bottom: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 5px;
}

.tab-link:hover {
    color: var(--primary-color);
}

.tab-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 500;
}

/* Page 1: Home / Index */
.home-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    padding-bottom: 100px;
}

.logo-large {
    font-size: 5rem;
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -2px;
    background: linear-gradient(45deg, #6c5ce7, #00cec9);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.buttons-container {
    margin-top: 30px;
    display: flex;
    gap: 12px;
}

.btn {
    background-color: var(--hover-bg);
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-color);
    font-size: 14px;
    padding: 0 16px;
    height: 36px;
    line-height: 34px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    border-color: var(--border-color);
    color: var(--text-color);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    color: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Page 2: Results */
.results-header-content {
    display: flex;
    align-items: center;
    gap: 30px;
    flex-grow: 1;
    width: 100%;
}

.logo-small {
    font-size: 1.8rem;
    font-weight: 700;
    text-decoration: none;
    background: linear-gradient(45deg, #6c5ce7, #00cec9);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    min-width: 80px;
}

.results-search-container {
    max-width: 690px;
    width: 100%;
}

.results-search-container .search-bar {
    height: 44px;
    box-shadow: none;
}

.results-search-container .search-bar:focus {
    box-shadow: var(--shadow-sm);
    border-color: transparent;
}

.results-main {
    padding: 20px 30px;
    max-width: 800px;
    margin-right: 180px;
    /* Align with search bar RTL */
    flex-grow: 1;
}

@media (max-width: 992px) {
    .results-main {
        margin-right: 0;
        padding: 20px;
    }
}

/* Result Items Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-item {
    margin-bottom: 30px;
    animation: fadeIn 0.5s ease forwards;
    opacity: 0;
}

.result-item:nth-child(1) {
    animation-delay: 0.1s;
}

.result-item:nth-child(2) {
    animation-delay: 0.2s;
}

.result-item:nth-child(3) {
    animation-delay: 0.3s;
}

.result-item:nth-child(4) {
    animation-delay: 0.4s;
}

.result-url {
    font-size: 14px;
    color: var(--text-color);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-icon {
    width: 24px;
    height: 24px;
    background-color: var(--hover-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--secondary-text);
    flex-shrink: 0;
}

.result-url cite {
    font-style: normal;
    color: var(--secondary-text);
    font-size: 12px;
}

.result-title {
    color: var(--link-color);
    font-size: 20px;
    font-weight: 400;
    text-decoration: none;
    display: block;
    margin-bottom: 4px;
    line-height: 1.3;
}

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

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

/* About, Privacy, Terms Pages */
.about-main {
    padding: 40px 30px;
    max-width: 800px;
    margin: 60px auto 0;
    flex-grow: 1;
    width: 100%;
}

.about-container {
    animation: fadeIn 0.5s ease forwards;
}

.about-container h1 {
    font-size: 32px;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-weight: 700;
}

.about-container .subtitle {
    font-size: 18px;
    color: var(--secondary-text);
    margin-bottom: 40px;
    font-weight: 300;
}

.about-section {
    margin-bottom: 40px;
}

.about-section h2 {
    font-size: 22px;
    color: var(--text-color);
    margin-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    display: inline-block;
}

.about-section p {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-color);
    margin-bottom: 15px;
}

.about-section ul {
    list-style-type: none;
    padding-right: 0;
}

.about-section ul li {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-color);
    margin-bottom: 10px;
    padding-right: 20px;
    position: relative;
}

.about-section ul li::before {
    content: "•";
    color: var(--primary-color);
    font-weight: bold;
    font-size: 20px;
    position: absolute;
    right: 0;
    top: -2px;
}

/* Contact Page specific */
.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

@media (max-width: 768px) {
    .contact-grid {
        grid-template-columns: 1fr;
    }
}

.contact-info .contact-list {
    list-style: none;
    padding: 0;
}

.contact-info .contact-list li {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    font-size: 16px;
    color: var(--text-color);
}

.contact-info .contact-list li svg {
    color: var(--primary-color);
    flex-shrink: 0;
}

.contact-form-wrapper {
    background-color: var(--hover-bg);
    padding: 30px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.contact-form-wrapper h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--text-color);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 500;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus {
    border-color: var(--primary-color);
}

/* Auth Pages */
.auth-page .home-main {
    justify-content: center;
    padding-top: 40px;
}

.auth-container {
    width: 100%;
    max-width: 450px;
    background-color: var(--bg-color);
    padding: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.auth-header {
    margin-bottom: 30px;
}

.auth-header h1 {
    font-size: 24px;
    color: var(--text-color);
    margin-bottom: 10px;
}

.auth-header p {
    color: var(--secondary-text);
}

.social-login {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.social-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.social-btn:hover {
    background-color: var(--hover-bg);
}

.divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--secondary-text);
    font-size: 14px;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background-color: var(--border-color);
}

.divider span {
    padding: 0 10px;
}

.auth-footer {
    margin-top: 20px;
    font-size: 14px;
    color: var(--secondary-text);
}

.auth-footer a {
    color: var(--primary-color);
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-color);
}

/* Footer */
.result-icon img {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

/* Pagination Styles */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 40px;
    margin-bottom: 50px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: 4px;
    background-color: var(--hover-bg);
    color: var(--text-color);
    font-size: 14px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.page-link:hover {
    background-color: var(--border-color);
    border-color: var(--secondary-text);
}

.page-link.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: bold;
}

.main-footer {
    background-color: var(--footer-bg);
    padding: 15px 30px;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-link {
    color: var(--footer-text);
}

.footer-link:hover {
    text-decoration: underline;
}

.highlight {
    font-weight: bold;
    color: var(--text-color);
}