/*
  This file is part of MediaWiki Code2Code Search
  <https://github.com/ftosoni/mediawiki-code2code-search>.
  Copyright (c) 2026 Francesco Tosoni.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
*/
/* --- Global Link Styling --- */
a {
    text-decoration: none;
    transition: color 0.3s ease, opacity 0.3s ease, text-decoration 0.3s ease;
}

a:hover {
    text-decoration: underline;
}

:root {
    --bg-dark: #050505;
    /* Indian Saffron (Kesari) */
    --accent-india: #FF7722;
    /* Savoy Blue */
    --accent-italy: #4B61D1;
    --text-main: #e0e0e0;
    --glass: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Ubuntu', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
    height: 100vh;
}

#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

#root {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    background: radial-gradient(circle at center, transparent 0%, var(--bg-dark) 95%);
}

.header {
    margin-top: 6vh;
    text-align: center;
    margin-bottom: 2.5rem;
    animation: fadeIn 1.5s ease-out;
}

.header h1 {
    font-family: 'Ubuntu', sans-serif;
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -2px;
    background: linear-gradient(135deg, var(--accent-india), var(--accent-italy));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.header p {
    font-weight: 300;
    opacity: 0.6;
    font-size: 0.9rem;
    letter-spacing: 4px;
    text-transform: uppercase;
}

.search-container {
    width: 90%;
    max-width: 800px;
    background: var(--glass);
    backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    padding: 2rem;
    box-shadow: 0 12px 80px rgba(0, 0, 0, 0.7);
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.search-container:focus-within {
    border-color: rgba(255, 140, 0, 0.6);
    transform: translateY(-4px);
    box-shadow: 0 16px 100px rgba(255, 140, 0, 0.2);
}

textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.1rem;
    resize: none;
    outline: none;
    min-height: 180px;
    margin-bottom: 1.5rem;
    line-height: 1.6;
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.search-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-pill {
    font-size: 0.7rem;
    color: #aaa;
    background: rgba(255, 255, 255, 0.06);
    padding: 5px 14px;
    border-radius: 20px;
    letter-spacing: 1px;
    font-weight: 600;
}

.search-btn {
    background: linear-gradient(135deg, var(--accent-india), var(--accent-italy));
    border: none;
    color: white;
    padding: 1.1rem 3rem;
    border-radius: 50px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.85rem;
    box-shadow: 0 6px 20px rgba(255, 140, 0, 0.4);
}

.search-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(255, 140, 0, 0.6);
}

.search-btn:disabled {
    filter: grayscale(1);
    opacity: 0.4;
    cursor: wait;
}

/* Language Selector UI */
.lang-selector {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1000;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 6px 12px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.lang-selector:hover {
    border-color: var(--accent-india);
    background: rgba(255, 255, 255, 0.08);
}

.lang-selector select {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    outline: none;
    text-transform: uppercase;
}

.lang-selector option {
    background: #111;
    color: #fff;
}

.results {
    width: 95%;
    max-width: 950px;
    margin-top: 4rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    padding-bottom: 15vh;
}

.result-card {
    background: var(--glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    padding: 2.5rem;
    animation: slideUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
}

.result-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: linear-gradient(to bottom, var(--accent-india), var(--accent-italy));
    opacity: 0.8;
}

.result-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(12px) scale(1.01);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    width: 100%;
    gap: 2rem;
}

.file-info h3 {
    color: var(--accent-india);
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-family: 'Ubuntu', sans-serif;
}

.swhid-link {
    color: var(--accent-italy);
    text-decoration: none;
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
    opacity: 0.6;
    transition: all 0.2s;
    display: inline-block;
    margin-top: 0.8rem;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    word-break: break-all;
    white-space: normal;
}

.swhid-link:hover {
    opacity: 1;
    background: rgba(147, 112, 219, 0.2);
}

.score-box {
    text-align: right;
    background: rgba(255, 153, 51, 0.08);
    padding: 12px 20px;
    border-radius: 16px;
    border: 1px solid rgba(255, 153, 51, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 150px;
}

.score-item {
    display: flex;
    flex-direction: column;
}

.score-label {
    font-size: 0.6rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 2px;
}

.score-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    font-family: 'Ubuntu', sans-serif;
}

.score-value.rank {
    color: var(--accent-india);
    font-size: 1.3rem;
}

pre {
    background: rgba(0, 0, 0, 0.5);
    padding: 1.8rem;
    border-radius: 20px;
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.95rem;
    overflow-x: auto;
    color: #cbd5e1;
    line-height: 1.6;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

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

.loader {
    width: 70px;
    height: 70px;
    border: 5px solid rgba(255, 255, 255, 0.05);
    border-bottom-color: var(--accent-india);
    border-radius: 50%;
    display: inline-block;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.result-card pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    border-radius: 16px;
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.03);
    margin: 0;
}

/* Collapsible Code Styles */
.code-wrapper {
    position: relative;
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    overflow: hidden;
    border-radius: 16px;
}

.code-wrapper.collapsed {
    max-height: 300px;
}

.code-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: linear-gradient(to top, rgba(5, 5, 5, 0.95), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.code-wrapper.collapsed .code-gradient {
    opacity: 1;
}

.expand-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--accent-india);
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    text-transform: uppercase;
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.group-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 90%;
    max-width: 800px;
    padding: 10px 0;
}

.group-chip {
    background: rgba(75, 97, 209, 0.1);
    border: 1px solid rgba(75, 97, 209, 0.2);
    color: #8DA2FB;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    letter-spacing: 1px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.group-chip:hover {
    background: rgba(75, 97, 209, 0.2);
    border-color: var(--accent-italy);
    color: #fff;
}

.group-chip.active {
    background: rgba(75, 97, 209, 0.3);
    border-color: var(--accent-italy);
    color: #fff;
    box-shadow: 0 0 15px rgba(75, 97, 209, 0.4);
}

/* Specific style for default 'ALL' buttons */
.all-chip {
    border-style: dashed;
    font-weight: 800;
    border-width: 1.5px;
    opacity: 0.8;
}

.group-chip.all-chip.active {
    background: var(--accent-italy);
    border-style: solid;
    color: #fff;
    box-shadow: 0 0 25px rgba(75, 97, 209, 0.6);
    opacity: 1;
}

.lang-chip {
    background: rgba(255, 119, 34, 0.05);
    border: 1px solid rgba(255, 119, 34, 0.2);
    color: #FFB380;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.lang-chip:hover {
    background: rgba(255, 119, 34, 0.15);
    border-color: var(--accent-india);
    color: #fff;
}

.lang-chip.active {
    background: var(--accent-india);
    border-style: solid;
    color: #fff;
    box-shadow: 0 0 20px rgba(255, 119, 34, 0.5);
    opacity: 1;
}

/* Lang version of all-chip */
.lang-chip.all-chip {
    border-color: rgba(255, 119, 34, 0.3);
    border-style: dashed;
    font-weight: 800;
}

.type-selector {
    display: flex;
    gap: 8px;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.type-chip {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    color: #777;
    padding: 5px 12px;
    border-radius: 50px;
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.type-chip:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #aaa;
}

.type-chip.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-india);
    color: var(--accent-india);
}


/* --- Pygments Syntax Highlighting (Custom Dark Theme) --- */
.code-wrapper pre code {
    white-space: pre;
    word-spacing: normal;
    word-break: normal;
    word-wrap: normal;
}

/* Keywords */
.k, .kc, .kd, .kn, .kp, .kr, .kt { color: #8da2fb; font-weight: bold; }
/* Comments */
.c, .cm, .c1, .cs { color: #666; font-style: italic; }
/* Strings */
.s, .sa, .sb, .sc, .dl, .sd, .s2, .se, .sh, .si, .sx, .sr, .s1, .ss { color: #00FF7F; }
/* Numbers */
.m, .mb, .mf, .mh, .mi, .mo, .il { color: #FF9933; }
/* Names/Functions */
.nf, .fm { color: #E1B0FF; }
/* Classes/Types */
.nc, .nn { color: #FFD700; text-decoration: underline; text-decoration-color: rgba(255,215,0,0.3); }
/* Operators/Punctuation */
.o, .p { color: #aaa; }
/* Builtins */
.nb, .bp { color: #8da2fb; font-style: italic; }
/* Decorators/Attributes */
.nd, .na { color: #FF8C00; }
/* Errors */
.err { border: 1px solid #ff0000; }

@media (max-width: 768px) {
    #root {
        padding: 1rem;
    }

    .header h1 {
        font-size: 2.2rem;
        letter-spacing: -1px;
    }

    .lang-selector {
        top: 1rem;
        right: 50%;
        transform: translateX(50%);
        width: auto;
        max-width: 90%;
        justify-content: center;
    }

    .search-container {
        padding: 1.2rem;
        width: 100%;
        border-radius: 20px;
    }

    textarea {
        min-height: 120px;
        font-size: 1rem;
    }

    .group-selector {
        width: 100%;
        gap: 6px;
    }

    .group-chip {
        padding: 6px 12px;
        font-size: 0.65rem;
    }

    .type-selector {
        justify-content: center;
    }

    .search-btn {
        padding: 0.8rem 2rem;
        width: 100%;
    }

    .search-footer {
        flex-direction: column;
        gap: 1rem;
    }

    .result-card {
        padding: 1.2rem;
        border-radius: 20px;
        max-width: 100%;
        overflow-x: hidden;
    }

    .result-card:hover {
        transform: none !important;
    }

    .result-header {
        flex-direction: column;
        gap: 1.5rem;
    }

    .score-box {
        width: 100%;
        flex-direction: row;
        justify-content: space-around;
    }
}
