:root {
    --primary: #003c2f;
    --primary-hover: #002b21;
    --bg-light: #ffffff;
    --bg-card: #f9f9f9;
    --text-main: #1a1a1a;
    --text-muted: #666666;
    --border-light: #eeeeee;
    --accent: #eb5e55;
    --success: #2d6a4f;
    --font-serif: 'Playfair Display', serif;
    --font-sans: 'Montserrat', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-sans);
}

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

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem 0;
    border-bottom: 1px solid var(--border-light);
}

.brand-logo {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    color: var(--primary);
    text-transform: lowercase;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

p.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}


.glass-card {
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.upload-section h2,
.search-section h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

/* Upload Area */
.upload-zone {
    border: 2px dashed var(--border-light);
    border-radius: 12px;
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fcfcfc;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: #f7f9f9;
}

/* Management Controls */
.admin-controls-bar {
    width: 100%;
}

.btn-secondary {
    background: var(--primary);
    color: white;
    padding: 0.8rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    transition: 0.3s;
}

.btn-secondary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* Search Interface */
.hero-search-container {
    padding: 6rem 0;
    transition: all 0.6s cubic-bezier(0.19, 1, 0.22, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hero-search-container.results-active {
    padding: 2rem 0;
    border-bottom: 1px solid var(--border-light);
}

.search-box-wrapper {
    width: 100%;
    max-width: 700px;
    position: relative;
}

input[type="text"] {
    width: 100%;
    border: 1px solid var(--border-light);
    border-radius: 50px;
    padding: 1.2rem 4rem 1.2rem 2rem;
    font-size: 1.1rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
    outline: none;
    transition: 0.3s;
}

input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 4px 30px rgba(0, 60, 47, 0.1);
}

.search-icon-btn {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1.2rem;
    cursor: pointer;
}

/* RAG Answer Box */
.rag-box {
    background: #fff;
    border: 1px solid #ffccd5;
    border-top: 4px solid var(--accent);
    border-radius: 8px;
    padding: 2rem;
    margin: 2rem 0;
    line-height: 1.8;
}

.rag-box h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

/* Result Cards */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.result-card {
    display: flex;
    gap: 2rem;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-light);
}

.result-card:last-child {
    border-bottom: none;
}

.result-card img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 4px;
}

.result-info {
    flex: 1;
}

.result-type {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-title {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.result-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-style: italic;
}

.result-snippet {
    font-size: 0.95rem;
    color: #444;
    margin-bottom: 1.5rem;
}

.btn-link {
    color: var(--text-main);
    text-decoration: underline;
    font-size: 0.9rem;
    font-weight: 600;
}

/* History Styles */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.history-item {
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-glass);
    cursor: pointer;
    transition: transform 0.2s;
}

.history-item:hover {
    transform: scale(1.05);
}

.history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.empty-msg {
    grid-column: 1 / -1;
    text-align: center;
    opacity: 0.5;
    font-style: italic;
    padding: 1rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: white;
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

.vertex-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(74, 222, 128, 0.1);
    color: var(--success);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 1rem;
    border: 1px solid rgba(74, 222, 128, 0.2);
}

/* Search Area */
.search-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

input[type="text"] {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: 0.3s;
}

input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(192, 132, 252, 0.1);
}

.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}



/* Utilities */
.status {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.status.info {
    background: rgba(192, 132, 252, 0.1);
    color: var(--primary);
}

.status.success {
    background: rgba(74, 222, 128, 0.1);
    color: var(--success);
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
    display: none;
    margin: 1rem auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


.selection-check {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 10;
    display: none;
}

.history-item:hover .selection-check {
    display: block;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* --- MOBILE RESPONSIVENESS (Refined) --- */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .brand-logo {
        font-size: 2rem;
    }

    /* Better Nav on Mobile */
    .main-nav {
        gap: 1.25rem 1.5rem;
        /* Increased vertical gap */
        justify-content: center;
        flex-wrap: wrap;
        /* Wrap instead of scroll if scroll is failing */
        padding: 1rem 0.5rem;
        /* More vertical space */
    }

    .nav-btn,
    .nav-link-mock {
        font-size: 0.85rem;
        /* Slightly larger for touch */
        padding: 0.5rem;
    }

    /* Result Cards Stacked on Mobile */
    .result-card {
        flex-direction: column;
        gap: 1rem;
        padding: 1.5rem 0;
    }

    .result-card img {
        width: 100%;
        height: auto;
        aspect-ratio: 1/1;
        border-radius: 8px;
    }

    .result-title {
        font-size: 1.2rem;
    }

    /* Hero & Forms */
    .hero-search-container {
        padding: 4rem 1rem;
    }

    input[type="text"] {
        padding: 1rem 3.5rem 1rem 1.5rem;
        font-size: 1rem;
    }

    /* Admin & Dashboard */
    .admin-controls-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .admin-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .table-container {
        margin: 0 -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding-bottom: 1rem;
    }

    .admin-table {
        font-size: 0.8rem;
        min-width: 500px;
        /* Force scroll on really small screens */
    }

    .wp-sync-box {
        padding: 1.5rem 1rem;
    }

    .modal-content {
        padding: 1.2rem;
        width: 95%;
        margin: 10% auto;
    }

    .management-header {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        text-align: center;
    }
}

/* Scroll Top Button */
.scroll-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    z-index: 1000;
    transition: all 0.3s;
}

.scroll-top:hover {
    background: var(--primary-hover);
    transform: translateY(-5px);
}

.scroll-top.visible {
    display: flex;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* --- NAVIGATION & TABS --- */
.main-nav {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    justify-content: center;
    align-items: center;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    letter-spacing: 0.05em;
}

.nav-btn,
.nav-link-mock {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: var(--font-sans) !important;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    line-height: 1.2;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    text-decoration: none;
}

/* Specific styling for RONDA to match user reference */
.nav-link-mock:last-child {
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    border-bottom: none;
}

.nav-btn.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

.nav-btn:hover,
.nav-link-mock:hover {
    color: var(--primary);
}

.tab-content {
    display: none;
    animation: fadeInTab 0.4s ease-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeInTab {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* --- ADMIN UI --- */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 1.5rem;
}

.admin-header h2 {
    font-family: var(--font-serif);
    margin: 0;
}

.rag-control {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Switch Styling - Refined for precision */
.switch {
    position: relative;
    display: flex;
    align-items: center;
    width: 46px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    background-color: white;
    transition: .4s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(24px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.management-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.table-container {
    overflow-x: auto;
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    width: 100%;
}

.wp-sync-box {
    margin-bottom: 3rem;
    padding: 2rem;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 12px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

.admin-table th,
.admin-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.admin-doc-id {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--primary-light);
    cursor: pointer;
    text-decoration: underline;
    opacity: 0.8;
}

.admin-doc-id:hover {
    opacity: 1;
    color: var(--primary);
}

.admin-table th {
    background: #f8f9fa;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.admin-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
}

.btn-danger {
    background: rgba(244, 63, 94, 0.2);
    color: #fb7185;
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
    background: #f43f5e;
    color: white;
}

/* RAG Result Styling */
.rag-box {
    background: linear-gradient(135deg, rgba(192, 132, 252, 0.1), rgba(126, 34, 206, 0.1));
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(192, 132, 252, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.5s ease-out;
}

.rag-box h4 {
    color: var(--primary-light);
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

/* Enhanced Metadata Modal */
.tag-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 3px 2px;
    transition: all 0.2s;
}

.tag-pill:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-1px);
}

.modal-data-content h2 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.info-card strong {
    color: var(--primary);
    font-size: 1rem;
}

.modal-image-sidebar img {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.result-tags {
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* --- MODAL SYSTEM --- */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeInModal 0.3s ease;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    margin: 5% auto;
    padding: 3rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    max-width: 1000px;
    position: relative;
    animation: slideUpModal 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

.close-modal {
    color: var(--text-muted);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    line-height: 1;
}

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

@keyframes fadeInModal {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUpModal {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

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

/* Result Card Index Badge */
.index-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--accent);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    z-index: 10;
    border: 2px solid white;
}

.result-card {
    position: relative;
    /* Ensure badge is positioned correctly */
}