/* Global Styles */
body {
    background-color: black;
    font-family: 'Space Grotesk', sans-serif;
}
.grid-background {
    background-image: radial-gradient(rgba(30,144,255,0.25) 1px, transparent 1px);
    background-size: 40px 40px;
}

/* Gradient Border Effect */
.gradient-border {
    position: relative;
    border-radius: 6px;
    overflow: visible; /* Changed from hidden to allow tooltips to be visible */
}
.gradient-border::before {
    content: "";
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    z-index: -1;
    border-radius: 8px;
    background: linear-gradient(45deg, #0047ab, #1e90ff, #00bfff, #1e90ff, #0047ab);
    background-size: 300% 300%;
    animation: gradientMove 10s ease infinite;
    filter: blur(1px);
    opacity: 0.9;
}
@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Metallic Text Effect */
.metallic-text {
    background: linear-gradient(to right, #83a4d4, #fff, #b6fbff, #fff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    background-size: 200% auto;
    animation: shine 3s linear infinite;
    letter-spacing: 2px;
    text-shadow: 0 0 15px rgba(135,206,250,0.4);
}
@keyframes shine {
    to { background-position: 200% center; }
}

/* Input Placeholder */
input::placeholder {
    color: rgba(176,224,255,0.6);
}

/* Suggestions Dropdown */
#suggestions {
    position: absolute;
    top: 105%;
    left: 0;
    width: 100%;
    background-color: rgba(0,0,0,0.95);
    border: 1px solid rgba(0,71,171,0.5);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3), 0 0 10px rgba(30,144,255,0.2);
    z-index: 9999;
    max-height: 300px;
    overflow-y: auto;
}
.suggestion {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 2px solid rgba(30,144,255,0.3);
    text-align: left;
}
.suggestion:last-child {
    border-bottom: none;
}
.suggestion:hover,
.suggestion.active {
    background-color: rgba(30,58,138,0.8);
    color: #fff;
}

/* --- Engine Selector Styles --- */
/* Container for the entire engine selector */
.engine-selector-container {
    position: relative;
    width: 40px;
    height: 40px;
    margin-right: 10px;
    z-index: 30;
}

/* Main button (always visible) */
.engine-selector-main {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    border: 1px solid rgba(59,130,246,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    z-index: 31;
    transition: box-shadow 0.3s ease;
}

.engine-selector-main:hover {
    box-shadow: 0 0 10px rgba(59,130,246,0.5);
}

/* Engine options container */
.engine-options {
    position: absolute;
    top: 0;
    left: 0;
    height: 40px;
    background: rgba(13,25,45,0.95);
    border-radius: 20px;
    display: flex;
    align-items: center;
    padding-left: 40px; /* Space for the main button */
    padding-right: 10px;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transform: scaleX(0.3);
    transform-origin: left;
    transition: all 0.3s ease;
    z-index: 29;
    border: 1px solid rgba(59,130,246,0.3);
    width: 420px; /* Increased width to accommodate all icons */
    overflow: visible; /* Allow tooltips to be visible outside the container */
}

/* When expanded, show the options */
.engine-selector-container.expanded .engine-options {
    opacity: 1;
    visibility: visible;
    transform: scaleX(1);
}

/* Individual engine option buttons */
.engine-option {
    width: 36px;
    height: 36px;
    margin: 0 5px;
    border-radius: 50%;
    background: rgba(13,25,45,0.8);
    border: 1px solid rgba(59,130,246,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.engine-option:hover {
    transform: translateY(-3px);
    background: rgba(30,64,175,0.7);
    border-color: rgba(59,130,246,0.8);
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

/* SVG icons styling */
.engine-option svg,
.engine-selector-main svg {
    width: 20px;
    height: 20px;
    color: #60a5fa;
    transition: color 0.2s ease;
    fill: currentColor;
}

.engine-option:hover svg,
.engine-selector-main:hover svg {
    color: #ffffff;
}

/* Adjust search input when engine selector is expanded */
#search-input {
    transition: padding-left 0.3s ease;
}

.engine-selector-container.expanded ~ #search-input {
    padding-left: 380px; /* Increased to match the new container width */
}

/* Ensure the search input text is visible during transition */
#search-input::placeholder {
    transition: opacity 0.3s ease;
}

.engine-selector-container.expanded ~ #search-input::placeholder {
    opacity: 0;
    transition-delay: 0s;
}

/* After expansion is complete, show placeholder again with padding */
.engine-selector-container.expanded ~ #search-input::placeholder {
    opacity: 1;
    transition-delay: 0.3s;
}

/* Ensure the engine options are visible on top of other elements */
.engine-selector-container.expanded {
    z-index: 9000;
}

/* Fix for SVG visibility */
.engine-option svg {
    pointer-events: none; /* Ensures clicks go to the button, not the SVG */
}

/* Active engine styling */
.engine-option.active {
    background: rgba(30,64,175,0.7);
    border-color: #ffffff;
    box-shadow: 0 0 10px rgba(59,130,246,0.7);
}

/* Tooltip Styles */
.engine-option {
    position: relative;
}

.engine-option::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -65px; /* Positioned further down */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(13,25,45,0.95);
    color: #60a5fa;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    border: 1px solid rgba(59,130,246,0.5);
    box-shadow: 0 0 8px rgba(59,130,246,0.4);
    text-shadow: 0 0 5px rgba(96,165,250,0.3);
    z-index: 9999;
    /* Ensure the tooltip is not clipped by parent containers */
    overflow: visible;
}

.engine-option:hover::after {
    opacity: 1;
    visibility: visible;
    bottom: -60px; /* Slight animation upward */
}

/* Pro Notification Styles */
#pro-plus-notification {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
    font-family: 'Space Grotesk', sans-serif;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    animation: slideInDown 0.3s ease-out forwards;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Mobile Circular Engine Selector */
@media (max-width: 768px) {
    /* Hide desktop engine selector on mobile */
    .engine-selector-container.expanded .engine-options {
        display: none;
    }
    
    /* Prevent search input padding changes on mobile */
    .engine-selector-container.expanded ~ #search-input {
        padding-left: 0;
    }
}

/* Circular Engine Modal for Mobile */
.engine-circular-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.engine-circular-modal.active {
    opacity: 1;
    visibility: visible;
}

.engine-circle-container {
    position: relative;
    width: 280px;
    height: 280px;
    transform: scale(0.8);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.engine-circular-modal.active .engine-circle-container {
    transform: scale(1);
}

/* Center selected engine */
.engine-center-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(147,197,253,0.1));
    border: 2px solid #60a5fa;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(59,130,246,0.4), 0 0 40px rgba(59,130,246,0.2);
    animation: centerPulse 2s ease-in-out infinite;
}

@keyframes centerPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(59,130,246,0.4), 0 0 40px rgba(59,130,246,0.2); }
    50% { box-shadow: 0 0 30px rgba(59,130,246,0.6), 0 0 60px rgba(59,130,246,0.3); }
}

.engine-center-icon svg {
    width: 32px;
    height: 32px;
    color: #60a5fa;
}

/* Circular positioned engine options */
.engine-circle-option {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(13,25,45,0.9);
    border: 2px solid rgba(59,130,246,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    transform-origin: center;
    /* perfect circle placement using polar coords */
    --r: 110px;
    --θ: 0deg;
    transform: translate(-50%, -50%) rotate(var(--θ)) translate(var(--r)) rotate(calc(-1 * var(--θ)));
}

.engine-circle-option:hover {
    transform: translate(-50%, -50%) rotate(var(--θ)) translate(var(--r)) rotate(calc(-1 * var(--θ))) scale(1.1);
    background: rgba(30,64,175,0.8);
    border-color: #60a5fa;
    box-shadow: 0 0 15px rgba(59,130,246,0.5);
}

.engine-circle-option svg {
    width: 28px;
    height: 28px;
    color: #60a5fa;
    fill: currentColor;
    transition: all 0.3s ease;
    pointer-events: none;
}

.engine-circle-option:hover svg {
    color: #ffffff;
    fill: currentColor;
}

/* Ensure SVG paths inherit the fill color */
.engine-circle-option svg path {
    fill: currentColor !important;
}

.engine-center-icon svg {
    width: 36px;
    height: 36px;
    color: #60a5fa;
    fill: currentColor;
}

.engine-center-icon svg path {
    fill: currentColor !important;
}

/* Evenly spaced positions around the circle (starting at top, clockwise) */
.engine-circle-option:nth-child(2) { --θ: -90deg; animation: fadeInCircle 0.6s ease-out 0.1s both; }
.engine-circle-option:nth-child(3) { --θ: -45deg; animation: fadeInCircle 0.6s ease-out 0.2s both; }
.engine-circle-option:nth-child(4) { --θ:   0deg; animation: fadeInCircle 0.6s ease-out 0.3s both; }
.engine-circle-option:nth-child(5) { --θ:  45deg; animation: fadeInCircle 0.6s ease-out 0.4s both; }
.engine-circle-option:nth-child(6) { --θ:  90deg; animation: fadeInCircle 0.6s ease-out 0.5s both; }
.engine-circle-option:nth-child(7) { --θ: 135deg; animation: fadeInCircle 0.6s ease-out 0.6s both; }
.engine-circle-option:nth-child(8) { --θ: 180deg; animation: fadeInCircle 0.6s ease-out 0.7s both; }
.engine-circle-option:nth-child(9) { --θ: 225deg; animation: fadeInCircle 0.6s ease-out 0.8s both; }

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

/* Close button */
.engine-modal-close {
    position: absolute;
    top: 40px;
    right: 40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(239,68,68,0.2);
    border: 2px solid rgba(239,68,68,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #ef4444;
}

.engine-modal-close:hover {
    background: rgba(239,68,68,0.3);
    border-color: #ef4444;
    transform: scale(1.1);
}

/* Engine labels for mobile */
.engine-circle-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #60a5fa;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.engine-circle-option:hover .engine-circle-label {
    opacity: 1;
}

/* Ripple effect on selection */
@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.engine-circle-option.selected::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: rgba(59,130,246,0.3);
    animation: ripple 0.6s ease-out;
}
