:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --text-primary: #2d2d2d;
    --text-secondary: #5f6368;
    --text-muted: #9aa0a6;
    --border-color: #e0e0e0;
    --accent-color: #1a0dab;
    --accent-hover: #0d47a1;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

[data-theme="dark"] {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-card: #2d2d2d;
    --text-primary: #e8eaed;
    --text-secondary: #bdc1c6;
    --text-muted: #9aa0a6;
    --border-color: #3c4043;
    --accent-color: #635BFF;
    --accent-hover: #5A52E5;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.4);
    --gradient: linear-gradient(135deg, #635BFF 0%, #4c46cc 100%);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.4;
    transition: all 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Header */
.header {
    background: linear-gradient(to bottom, #29248F, #0C0A29);
    color: white;
    padding: 30px 20px;
    text-align: center;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px var(--shadow);
}

.header-logo {
    width: 550px;
    max-width: 90%;
    height: auto;
    margin-bottom: 15px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.red-eye {

  animation: glowing 1s infinite;
}

@keyframes glowing {
  0% {
    fill: #950606;
    filter: drop-shadow(0 0 2px #B20000);
  }
  50% {
    fill: #FF0000;
    filter: drop-shadow(0 0 12px #FF0000);
  }
  100% {
    fill: #950606;
    filter: drop-shadow(0 0 2px #B20000);
  }
}


.header h2 {
    font-size: 40px;
    font-weight: 500;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.95);
}

.header p {
    opacity: 0.9;
    font-size: 18px;
}

/* Content Container for Static Pages */
.content-container {
    max-width: 900px;
    margin: 40px auto 0;
    padding: 40px 40px;
    background-color: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow);
    margin-bottom: 40px;
}

.content-container h1 {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    text-align: center;
    border-bottom: 3px solid var(--accent-color);
    padding-bottom: 15px;
}

.content-container h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 30px 0 15px 0;
    border-left: 4px solid var(--accent-color);
    padding-left: 15px;
}

.content-container h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 25px 0 12px 0;
}

.content-container p {
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 18px;
    text-align: justify;
}

.content-container ul {
    margin: 15px 0 20px 20px;
    padding-left: 0;
}

.content-container li {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 8px;
    list-style-type: disc;
    padding-left: 5px;
}

.content-container strong {
    color: var(--text-primary);
    font-weight: 600;
}

.content-container a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.content-container a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}


/* Main Container */
.search-container {
    max-width: 1330px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
    background-color: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow);
    flex: 1;
    box-sizing: border-box;
}

/* Engine Selection */
.controls {
    display: flex;
    justify-content: center;
    margin: 0 0 30px 30px;
}

.checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: center;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-color);
}

.engine-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
}

.engine-name {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 500;
}

.checkbox-item input:checked + .engine-icon + .engine-name {
    color: var(--accent-color);
}

/* Search Row */
.search-row {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.search-bar {
    flex: 1;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 12px var(--shadow);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.controls-right {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

/* Toggle Controls */
.view-toggle, .theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
}

.toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.toggle-icon svg {
    stroke: var(--text-secondary);
}

.toggle-icon.active svg {
    stroke: var(--accent-color);
}

#view-switch, #theme-switch {
    display: none;
}

.toggle-label {
    position: relative;
    width: 40px;
    height: 20px;
    background: var(--border-color);
    border-radius: 10px;
    cursor: pointer;
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

#view-switch:checked + .toggle-label,
#theme-switch:checked + .toggle-label {
    background: var(--accent-color);
}

#view-switch:checked + .toggle-label .toggle-slider,
#theme-switch:checked + .toggle-label .toggle-slider {
    transform: translateX(20px);
}

[data-theme="dark"] .toggle-slider {
    background: var(--text-primary);
}

#query {
    padding: 16px 20px;
    border: none;
    font-size: 16px;
    flex-grow: 1;
    outline: none;
    background-color: #ffffff;/*var(--bg-card);*/
    /*color: var(--bg-primary);*/
    color: #333333
}

#query::placeholder {
    color: var(--text-muted);
}

/*#query:focus {
    box-shadow: 0 0 0 2px var(--accent-color) inset;
}*/

button {
    padding: 16px 32px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
}

button:hover {
    background-color: var(--accent-hover);
}

/* Category Tabs */
.category-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: 12px;
}

.tab-link .fa-solid, .fas {
    font-size: 20px;
}

.tab-link {
    padding: 8px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    gap: 8px;
    display: flex;
    align-items: center;
}

.tab-link.active {
    background: var(--accent-color);
    color: white;
}

/* Engine Results */
.engine-results {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 20px;
    box-sizing: border-box;
    background-color: var(--bg-card);
    overflow: hidden;
    transition: all 0.3s ease;
}

.engine-results h3 {
    margin: 0;
    padding: 18px 20px;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    gap: 10px;
}

.engine-results h3 img {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.results-content {
    max-height: 400px;
    overflow-y: auto;
    padding: 20px;
    color: var(--text-primary);
}

.results-content ol {
    list-style: none;
    counter-reset: result-counter;
    padding: 0;
}

.results-content li {
    counter-increment: result-counter;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    min-height: 50px;
}

.results-content li::before {
    content: counter(result-counter);
    position: relative;
    left: 0;
    top: 0;
    background: var(--accent-color);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 5px;
}

/* Style for your JavaScript's floated thumbnails */
.results-content li img[style*="float"] {
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.results-content li img[style*="float"]:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px var(--shadow);
}

/* Ensure proper spacing for result content */
.results-content li .result-url {
    font-size: 13px;
    color: #006621;
    margin-bottom: 4px;
}

[data-theme="dark"] .results-content li .result-url {
    color: #81c995;
}

.search-result {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem !important;
}

/* Thumbnail Support for General Search */
.result-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.result-thumbnail {
    flex-shrink: 0;
    max-width: 120px;
    max-height: 90px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.result-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px var(--shadow);
}

.result-text {
    flex: 1;
    min-width: 0;
}

.results-content li:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.results-content a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    display: block;
    margin-bottom: 6px;
    font-size: 16px;
    line-height: 1.3;
}

.results-content a:hover {
    text-decoration: underline;
}

.results-content p {
    color: var(--text-secondary);
    margin: 8px 0 0 0;
    font-size: 14px;
    line-height: 1.5;
}

/* Loading Animation */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 16px;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Layout Modes */
.results.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.results.grid.single-engine {
    grid-template-columns: 1fr;
}

.results.list {
    display: block;
}

.results.list .engine-results {
    width: 100%;
}

/* Status Bar */
.status-bar {
    background-color: var(--bg-secondary);
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* AI Summary */
.ai-summary {
    background: var(--gradient);
    border-radius: 12px;
    margin-bottom: 25px;
    overflow: hidden;
    box-shadow: 0 4px 20px var(--shadow);
    display: none;
}

.ai-summary-header {
    padding: 15px 25px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-summary-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-summary-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.ai-summary-controls {
    display: flex;
    gap: 10px;
}

.ai-summary-controls button {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.ai-summary-controls button:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
}

.ai-summary-content {
    background-color: var(--bg-card);
    padding: 25px;
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 15px;
    height: 300px;
    min-height: 150px;
    overflow: auto;
    resize: vertical;
    position: relative;
}

.ai-summary-content.loading {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 30px 25px;
    max-height: none;
    overflow: visible;
}

.ai-summary-content.loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

/* Footer */
.footer {
    background-color: #000000;
    padding: 30px 20px;
    margin-top: 40px;
    text-align: center;
    color: #e8eaed;
}

.footer-logo {
	max-width: 275px;
	margin: 0 auto 20px;
}

.footer-links {
    margin-bottom: 30px;
}

.footer-links a {
    color: #635bff;
    text-decoration: none;
    font-size: 14px;
    margin: 0 15px;
}

.footer-links a:hover {
    color: #a39eff;
}

.footer-links a:active {
    color: #a39eff;
}

.footer-copyright {
    color: #bdc1c6;
    font-size: 14px;
    font-weight: 400;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .search-container {
        margin: 0 10px;
        padding: 15px;
    }

    .logo {
        width: 450px;
        margin-bottom: 12px;
    }

    .header {
        padding: 25px 20px;
    }

    .header h2 {
        font-size: 32px;
    }

    .results.grid {
        grid-template-columns: 1fr;
    }

    .search-row {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .controls-right {
        justify-content: center;
        gap: 10px;
    }

    .checkboxes {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px 10px;
        justify-content: center;
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
    }

    .engine-icon {
        width: 32px;
        height: 32px;
    }

    .engine-name {
        font-size: 14px;
    }

	.category-tabs {
    	display: flex;
    	justify-content: flex-start !important;
    }

    /* Thumbnail responsive */
    .result-header {
        flex-direction: column;
        gap: 8px;
    }

    .result-thumbnail {
        max-width: 100%;
        max-height: 150px;
        align-self: center;
    }
}

@media (max-width: 480px) {
    .logo {
        width: 320px;
        margin-bottom: 10px;
    }

    .header h2 {
        font-size: 24px;
    }

    .search-container {
        margin: 0 5px;
        padding: 10px;
    }

    .engine-icon {
        width: 28px;
        height: 28px;
    }

    .engine-name {
        font-size: 13px;
    }
}

/* === Corrected Styling for Individual Results === */
.results-content li {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px 24px 20px 60px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px var(--shadow);
  position: relative;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.results-content li:hover {
  background-color: var(--bg-secondary);
  transform: scale(1.01);
}

/* Restore and restyle result counter */
.results-content li::before {
  content: counter(result-counter);
  position: absolute;
  left: 20px;
  top: 20px;
  background: var(--accent-color);
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 6px var(--shadow);
}

.ai-summary-content::before {
    content: '';
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 15px;
    height: 15px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='7 13 12 18 17 13'%3E%3C/polyline%3E%3Cpolyline points='7 6 12 11 17 6'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    opacity: 0.6;
    pointer-events: none; /* So it doesn't interfere with the native handle */
}

/* === SearXNG-Style Result Formatting === */

/* General result articles */
.result {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px var(--shadow);
    transition: box-shadow 0.2s ease;
}

.result:hover {
    box-shadow: 0 4px 8px var(--shadow-hover);
}

.result h3 {
    margin: 8px 0 4px 0;
    font-size: 18px;
    line-height: 1.3;
}

.result h3 a {
    color: var(--accent-color);
    text-decoration: none;
}

.result h3 a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.result .url_header {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 4px;
    display: block;
}

.result .url_wrapper {
    display: inline;
}

.result .url_o1 .url_i1 {
    color: var(--text-secondary);
}

.result .thumbnail {
    border-radius: 4px;
    box-shadow: 0 2px 4px var(--shadow);
}

.result .content {
    color: var(--text-primary);
    line-height: 1.5;
    margin: 8px 0;
}

.result .content.empty_element {
    color: var(--text-muted);
    font-style: italic;
}

.result .published_date {
    color: var(--text-secondary);
    font-size: 13px;
    margin-right: 12px;
}

.result .result_length,
.result .result_views,
.result .result_author {
    color: var(--text-secondary);
    font-size: 13px;
    margin-right: 12px;
    display: inline-block;
}

.result .engines {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.result .engines span {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-right: 6px;
}

.result .break {
    clear: both;
    height: 0;
}

/* Image results specific styling */
.result-images {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.result-images:hover {
    transform: scale(1.02);
}

.result-images .image_thumbnail {
    transition: opacity 0.2s ease;
}

.result-images:hover .image_thumbnail {
    opacity: 0.9;
}

.result-images .image_resolution {
    position: absolute;
    bottom: 30px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
}

.result-images .title {
    font-weight: 500;
    color: var(--text-primary);
}

.result-images .source {
    color: var(--text-muted);
}

/* Video results specific styling */
.result-videos .altlink {
    margin: 8px 0;
}

.result-videos .btn-collapse {
    background-color: var(--accent-color);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 13px;
    display: inline-block;
    transition: background-color 0.2s ease;
}

.result-videos .btn-collapse:hover {
    background-color: var(--accent-hover);
}

.result-videos .embedded-video {
    margin-top: 12px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px var(--shadow);
}

.result-videos .embedded-video.invisible {
    display: none;
}

.result-videos .embedded-video iframe {
    width: 100%;
    height: 315px;
    border: none;
}

/* === Modal Styles === */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: relative;
    background-color: var(--bg-card);
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-close {
    color: var(--text-secondary);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

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

.modal-navigation {
    display: flex;
    gap: 8px;
}

.modal-nav-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: background-color 0.2s ease;
}

.modal-nav-btn:hover {
    background-color: var(--accent-hover);
}

.modal-body {
    display: flex;
    max-height: calc(90vh - 80px);
    overflow: hidden;
}

.modal-image-container,
.modal-video-container {
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000;
    min-height: 400px;
}

.modal-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.modal-info {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--bg-card);
}

.modal-info h4 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 18px;
    line-height: 1.3;
}

.modal-info p {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.modal-info hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

.modal-metadata p {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 14px;
}

.modal-metadata span:first-child {
    font-weight: 500;
    color: var(--text-primary);
}

.modal-metadata a {
    color: var(--accent-color);
    text-decoration: none;
    word-break: break-all;
}

.modal-metadata a:hover {
    text-decoration: underline;
}

/* Responsive modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
        max-height: 85vh;
    }

    .modal-body {
        flex-direction: column;
    }

    .modal-image-container,
    .modal-video-container {
        min-height: 250px;
    }

    .modal-info {
        max-height: 300px;
    }

    .modal-navigation {
        display: none; /* Hide navigation on mobile for simplicity */
    }
}
