/* ========================================
   TEMA CENTRALIZZATO (Platform-UI-Standards)
   Sfondo e colori body/html delegati a theme-system.css.
   Nessun override scuro: light/dark seguono html[data-theme].
   ======================================== */

/* Icona agente nel page-title (sostituisce fa-search) */
.page-title .page-title-icon {
    height: 1.5rem;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

/* ========================================
   HERO INPUT SECTION (stile Agent_Diagram, integrato nel main container)
   Nessuna seconda card: un solo container visivo (main.container).
   ======================================== */
.hero-input-section--report.hero-input-section,
.hero-input-section.hero-input-section--report {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0 0 var(--space-4) 0;
    margin-bottom: var(--space-4);
}

.hero-input-section .input-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.hero-input-section .input-wrapper {
    position: relative;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 2px solid var(--border-color);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hero-input-section .input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.hero-input-section .main-input {
    width: 100%;
    min-height: 100px;
    padding: var(--space-4);
    padding-right: 4rem;
    border: none;
    outline: none;
    background: transparent;
    font-size: var(--font-size-lg);
    color: var(--text-primary);
    resize: vertical;
    font-family: inherit;
    line-height: 1.6;
}

.hero-input-section .main-input::placeholder {
    color: var(--text-muted);
}

.hero-input-section .input-actions {
    position: absolute;
    right: var(--space-3);
    top: var(--space-3);
    display: flex;
    gap: var(--space-2);
}

/* Microfono in registrazione (Speech Recognition) */
#task-mic-btn.recording,
#task-mic-btn.listening {
    color: var(--danger) !important;
    animation: pulse-recording 1.5s ease-in-out infinite;
}

@keyframes pulse-recording {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

html {
    scroll-behavior: smooth;
}

body.agent-page {
    font-family: var(--font-sans), 'Montserrat', sans-serif;
    color: var(--text-primary);
    line-height: 1.6;
    /* Sfondo dal tema centralizzato (theme-system.css) */
    background-color: var(--bg-body);
    background-image: none;
    position: relative;
}

.landing {
    display: flex;
    justify-content: center;
    align-items: center;
    height: calc(100vh - 40px);
    text-align: center;
    padding: 0 20px;
    margin-top: 0;
    /* Removed top margin that compensated for the top bar */
}

.landing h1 {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
}

.gradient-text {
    background-image: linear-gradient(to right, var(--primary), var(--primary-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
}

.landing p {
    font-size: 1.5rem;
    font-weight: 400;
    max-width: 1000px;
    padding: 0 25px 0 25px;
    margin: auto auto 2rem auto;
}

.landing-description {
    font-size: 20px;
}

.container {
    padding: var(--space-5);
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    transition: var(--transition-base);
}

.container:hover {
    /* Uncomment this to enable hover zoom effect (transform scale effect).
        This is not recommended because it can be obnoxious on desktop, and straight up unusable on mobile. */
    /* transform: scale(1.01); */
    box-shadow: var(--shadow-xl);
}

/* Glass-style inputs, selects, output areas */
input,
select,
#output,
#reportContainer {
    background-color: var(--bg-surface);
    border: none;
    color: var(--text-primary);
    transition: var(--transition-base);
}

input:hover,
input:focus,
select:hover,
select:focus {
    background-color: var(--bg-surface-alt);
    border: 1px solid var(--border-color-hover);
    box-shadow: var(--form-focus-shadow);
    transition: var(--transition-base);
}

.btn-primary {
    background: var(--gradient-primary);
    border: none;
    transition: var(--transition-base);
    font-size: 1.1rem;
    padding: var(--btn-padding-y) var(--btn-padding-x);
    border-radius: var(--btn-border-radius);
    min-width: 180px;
    text-align: center;
    box-shadow: 0 4px 15px var(--primary-light);
    font-weight: var(--btn-font-weight);
}

.btn-secondary {
    background: linear-gradient(to right, var(--gray-600), var(--gray-600));
    border: none;
    transition: var(--transition-base);
    font-size: 1.1rem;
    padding: var(--btn-padding-y) var(--btn-padding-x);
    border-radius: var(--btn-border-radius);
    min-width: 180px;
    text-align: center;
}

.btn-action {
    background: var(--bg-surface-alt);
    border: 1px solid var(--primary-light);
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.agent-question {
    font-size: 1.4rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

footer {
    position: relative;
    left: 0;
    bottom: 0;
    width: 100%;
    color: var(--text-primary);
    text-align: center;
    padding: var(--space-5) 0;
    margin-top: var(--space-10);
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--primary-light);
}

footer p {
    margin: 5px 0;
    font-size: 0.9rem;
}

footer a {
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition-fast);
}

footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.margin-div {
    margin-top: var(--space-5);
    margin-bottom: var(--space-5);
    padding: var(--card-padding);
    background-color: var(--bg-card);
    border-radius: var(--card-border-radius);
    border: 1px solid var(--border-color);
    transition: var(--transition-base);
}

.research-output-container,
.report-container {
    position: relative;
}

/* Visibilità a step: nascosti fino all'avvio della ricerca / al report */
.step-container.step-container--hidden {
    display: none !important;
}

.research-output-container h2,
.report-container h2 {
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-2xl);
    margin-bottom: 1.2rem;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 0.8rem;
    display: flex;
    align-items: center;
}

/* Explicitly override any icon that might be added before the h2 */
.research-output-container h2::before {
    content: none !important;
    display: none !important;
}

.report-container h2::before {
    content: '\f15c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-right: var(--space-3);
    color: var(--primary);
    font-size: var(--font-size-xl);
}

.images_div {
    padding: 0 25px 0 25px;
}

.agent_response {
    background-color: var(--bg-surface-alt);
    margin: var(--space-2);
    padding: var(--space-2);
    border-radius: var(--radius-md);
    animation: fadeIn 0.5s ease;
}

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

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

#output {
    height: 300px;
    overflow: auto;
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    margin-top: var(--space-3);
    border-radius: var(--radius-md);
}

#output::-webkit-scrollbar {
    width: 8px;
}

#output::-webkit-scrollbar-track {
    background: var(--bg-surface-alt);
    border-radius: 10px;
}

#output::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 10px;
}

#reportContainer {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 18px !important;
    background-color: transparent;
    border: none;
    color: var(--text-primary);
    transition: var(--transition-base);
    padding: var(--card-padding);
    border-radius: var(--radius-md);
}

#reportContainer h1,
#reportContainer h2,
#reportContainer h3 {
    color: var(--text-primary);
}

#reportContainer a {
    color: var(--primary);
    text-decoration: none;
}

#reportContainer a:hover {
    text-decoration: underline;
}

#reportContainer blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 15px;
    color: var(--text-secondary);
    font-style: italic;
}

.tags-input {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    border: 1px solid var(--border-color);
    padding: var(--space-1);
    border-radius: var(--radius-sm);
}

.tag {
    background-color: var(--primary);
    color: var(--gray-50);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
}

.tag .remove-tag {
    margin-left: 10px;
    cursor: pointer;
    font-weight: bold;
}

.tag-input {
    border: none;
    outline: none;
    flex-grow: 1;
}

.credits-bar {
    background: var(--bg-surface-alt);
    backdrop-filter: blur(10px);
    padding: 8px 0;
    width: 100%;
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.top-credits {
    position: fixed;
    top: 0;
    left: 0;
}

/* Bottom credits bar (download bar) */
.sticky-downloads-bar.credits-bar {
    position: fixed;
    bottom: 0;
    left: 0;
}

.credits-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.credits-bar p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    flex: 1;
}

/* Top history button styling */
.top-history-button {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    background: var(--bg-card);
    color: var(--primary);
    font-weight: 500;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
    justify-content: center;
}

.top-history-button:hover {
    background: var(--primary-2);
    color: var(--gray-50);
    transform: translateY(-2px);
}

.top-history-button i {
    font-size: 1rem;
}

/* Top WebSocket button styling */
.top-websocket-button {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    background: var(--bg-card);
    color: var(--primary);
    font-weight: 500;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
    justify-content: center;
    margin-left: var(--space-3);
}

.top-websocket-button:hover {
    background: var(--primary-2);
    color: var(--gray-50);
    transform: translateY(-2px);
}

.top-websocket-button i {
    font-size: 1rem;
}

/* Side feature panels */
.feature-panel {
    position: fixed;
    top: 80px;
    width: auto;
    max-width: 320px;
    z-index: 90;
    display: none;
    max-height: calc(100vh - 150px);
    overflow-y: visible;
    background: transparent;
    /* Add transition for smooth fading effect when panels appear */
    transition: opacity 0.5s ease;
}

.left-panel {
    left: 20px;
    right: auto;
}

.right-panel {
    right: 20px;
    left: auto;
}

.feature-panel::-webkit-scrollbar {
    width: 6px;
}

.feature-panel::-webkit-scrollbar-track {
    background: var(--bg-surface-alt);
    border-radius: 10px;
}

.feature-panel::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 10px;
}

.feature-card {
    background: var(--bg-card);
    backdrop-filter: blur(5px);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-left: 3px solid;
    transition: all 0.3s ease;
    cursor: pointer;
    min-height: 160px;
    width: 100%;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-surface);
    z-index: -1;
    opacity: 0.7;
    border-radius: inherit;
    pointer-events: none;
}

.feature-card:hover {
    transform: translateY(-5px);
    background: var(--bg-surface-alt);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-color-hover);
}

/* Adjust card colors to match background better */
.feature-card.primary {
    border-left-color: var(--primary);
}

.feature-card.success {
    border-left-color: var(--success);
}

.feature-card.info {
    border-left-color: var(--info);
}

.feature-card.warning {
    border-left-color: var(--warning);
}

.feature-card.danger {
    border-left-color: var(--danger);
}

.feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    font-size: var(--font-size-2xl);
    color: var(--gray-50);
    position: relative;
}

.feature-icon::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    transform: scale(0);
    transition: transform 0.3s ease;
}

.feature-card:hover .feature-icon::after {
    transform: scale(1);
}

.feature-card.primary .feature-icon {
    background: var(--gradient-primary);
}

.feature-card.success .feature-icon {
    background: linear-gradient(135deg, var(--success), var(--success-text));
}

.feature-card.info .feature-icon {
    background: linear-gradient(135deg, var(--primary), var(--info));
}

.feature-card.warning .feature-icon {
    background: linear-gradient(135deg, var(--warning), var(--warning-text));
}

.feature-card.danger .feature-icon {
    background: linear-gradient(135deg, var(--danger), var(--error-text));
}

.feature-title {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-xl);
    margin-bottom: var(--space-3);
    color: var(--gray-50);
}

.feature-text {
    color: var(--gray-400);
    font-size: var(--font-size-base);
    line-height: 1.6;
}

.feature-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.05));
    border-radius: 50%;
    transform: translate(50%, -50%);
    z-index: -1;
}

/* Animation for feature cards */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

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

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

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

.left-panel .feature-card {
    animation: fadeInLeft 0.6s ease forwards;
    opacity: 0;
}

.right-panel .feature-card {
    animation: fadeInRight 0.6s ease forwards;
    opacity: 0;
}

.feature-card:nth-child(1) {
    animation-delay: 0.1s;
}

.feature-card:nth-child(2) {
    animation-delay: 0.25s;
}

.feature-card:nth-child(3) {
    animation-delay: 0.4s;
}

/* Highlight connection between side panels and form elements */
.highlight-connection {
    transition: box-shadow 0.5s ease;
    position: relative;
    z-index: 1;
}

/* Button glow effect for feature cards interaction */
.highlight-glow-button {
    box-shadow: 0 0 25px 10px var(--primary-light) !important;
    border-color: var(--primary-2) !important;
    transform: translateY(-3px) !important;
    transition: all 0.3s ease !important;
}

/* Intensify highlight glows for feature-panel interactions */
.highlight-glow-container {
    box-shadow: 0 0 30px 15px var(--primary-light) !important;
    border: 1px solid var(--primary-2) !important;
}

.highlight-glow-report_source,
.highlight-glow-query_domains {
    box-shadow: 0 0 20px 10px var(--primary-light) !important;
}

.highlight-glow-tone {
    box-shadow: 0 0 20px 10px var(--primary-light) !important;
    border: 1px solid var(--primary-2) !important;
}

/* Ensure subtle transitions for all glows */
.highlight-connection,
.highlight-glow-container,
.highlight-glow-report_source,
.highlight-glow-query_domains,
.highlight-glow-tone {
    transition: box-shadow 0.5s ease;
}

/* Scroll to bottom button */
.scroll-to-bottom {
    display: none !important;
}

/* Responsive adjustments */
@media (min-width: 100px) {
    .feature-panel {
        display: block;
    }

    .container {
        max-width: 1980px !important;
    }
}

/* Medium devices (tablets, less than 1400px) */
@media (max-width: 1980px) {
    .feature-panel {
        display: none !important;
    }
}

@media (max-width: 991px) {
    .landing h1 {
        font-size: 2.5rem;
    }

    .landing p {
        font-size: 1.2rem;
    }

    .landing {
        margin-top: 50px;
    }

    .container {
        padding: 20px;
    }

    .btn-primary,
    .btn-secondary,
    .btn-action {
        padding: 10px 20px;
        margin-bottom: 10px;
    }

    #selectedImagesContainer img {
        width: 140px;
        height: 140px;
    }

    .scroll-to-bottom {
        width: 60px;
        height: 60px;
        bottom: 70px;
    }

    .credits-content {
        flex-wrap: wrap;
        justify-content: center;
    }

    .credits-bar p {
        width: 100%;
        text-align: center;
        margin-bottom: 5px;
    }

    .top-history-button,
    .top-websocket-button {
        margin: 5px;
    }

    .sticky-downloads-bar {
        padding: 8px 10px;
        bottom: 50px;
    }

    .download-option-btn {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    .history-panel {
        width: 100%;
    }

    .history-panel-toggle {
        right: 20px;
        bottom: 120px;
        top: auto;
    }

    .download-panel {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 60px;
        width: 100%;
        transform: none;
        padding: 0 15px;
        z-index: 99;
    }

    .download-panel-left,
    .download-panel-right {
        transform: none;
        left: 0;
        right: 0;
        margin: 0 auto;
        max-width: 300px;
    }

    .download-panel-right {
        bottom: 180px;
    }

    .download-card {
        margin-bottom: 10px;
    }

    .download-options {
        flex-direction: column;
        align-items: stretch;
        padding: 0 20px;
    }

    footer {
        padding: 10px 0;
    }

    .feature-panel {
        width: 100%;
        max-width: none;
        left: 0;
        right: 0;
        padding: 0 20px;
    }

    .feature-card {
        padding: 18px;
        min-height: auto;
    }
}

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

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

/* Modern spinner styles */
.modern-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    border: 3px solid var(--primary-2);
    border-top-color: var(--primary);
    vertical-align: middle;
    margin-right: var(--space-3);
}

/* Only apply spinning animation when the spinning class is added */
.modern-spinner.spinning {
    animation: spin 2s linear infinite;
}

/* Spinner in Research Progress title */
.research-output-container h2::before {
    content: '\f110';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-right: var(--space-3);
    color: var(--primary);
    font-size: var(--font-size-xl);
}

/* Add the styles from index.html */
.avatar {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-md);
    border: 2px solid var(--primary);
    box-shadow: var(--shadow-md);
}

.agent-name {
    text-align: center;
    font-weight: 600;
}

.agent-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

/* Hover effect to make panels reappear */
.feature-panel:hover {
    --panel-shift: 0px !important;
    --panel-opacity: 1 !important;
    --panel-rotate: 0deg !important;
    --panel-scale: 1 !important;
    box-shadow: none;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.5s ease, box-shadow 0.5s ease;
}

/* Add 3D shading effect to the panels */
.feature-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: none;
    z-index: -1;
    opacity: var(--panel-depth, 0.5);
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.feature-panel:hover::before {
    opacity: 0;
}

/* Add a subtle corner glow on hover */
.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top right, rgba(25, 25, 35, 0.15), transparent 70%);
    opacity: 0.5;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: -1;
}

.feature-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top right, transparent, rgba(10, 10, 15, 0.1) 70%);
    opacity: 1;
    z-index: -2;
}

/* Conversation History Panel */
.history-panel {
    position: fixed;
    top: 40px;
    right: 0;
    width: 320px;
    height: calc(100vh - 40px);
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-left: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: var(--shadow-xl);
}

.history-panel.open {
    transform: translateX(0);
}

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

.history-panel-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.history-panel-header h3 i {
    margin-right: 10px;
    color: var(--primary);
}

.history-panel-actions {
    display: flex;
}

.history-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.history-action-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.history-panel-search,
.history-panel-filters {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.history-panel-search input {
    flex: 1;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 15px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.history-panel-search button {
    margin-left: 8px;
}

.history-panel-filters select {
    flex: 1;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 15px;
    color: var(--text-primary);
    font-size: 0.9rem;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 15px;
}

.history-panel-entries {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg-surface-alt);
}

.history-panel-entries::-webkit-scrollbar {
    width: 6px;
}

.history-panel-entries::-webkit-scrollbar-track {
    background: var(--bg-surface-alt);
    border-radius: var(--radius-md);
}

.history-panel-entries::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: var(--radius-md);
}

.history-entry {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 15px;
    border-left: 3px solid var(--primary);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    cursor: pointer;
    animation: fadeInRight 0.3s ease forwards;
    opacity: 0;
    transform: translateX(20px);
}

@keyframes fadeInRight {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.history-entry:hover {
    background: var(--bg-surface-alt);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.history-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.history-entry-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    margin: 0;
    max-width: 80%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-entry-timestamp {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.history-entry-preview {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin: 0 0 var(--space-3) 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-entry-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    height: 0;
    overflow: hidden;
    transition: all 0.2s ease;
}

.history-entry:hover .history-entry-actions {
    opacity: 1;
    height: 32px;
    margin-top: 10px;
}

.history-entry-action {
    background: var(--bg-surface-alt);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-sm);
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-1);
    transition: all 0.2s ease;
    cursor: pointer;
}

.history-entry-action:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--text-primary);
}

.history-entry-action i {
    font-size: 0.8rem;
}

.history-entry-format {
    display: flex;
    gap: 5px;
    margin-top: 5px;
}

.history-entry-format span {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    background: var(--bg-surface-alt);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
}

.history-entry-format span i {
    color: var(--primary);
}

.history-entry-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.history-entry.expanded .history-entry-details {
    max-height: 200px;
    margin-top: 10px;
}

.history-entry-detail {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin: var(--space-1) 0;
}

.history-panel-toggle {
    position: fixed;
    top: 100px;
    right: var(--space-8);
    left: auto;
    width: 70px;
    height: 70px;
    background: var(--gradient-primary-135);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--gray-50);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 999;
}

.history-panel-toggle:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl);
}

.history-panel-toggle i {
    font-size: 26px;
    margin-bottom: 5px;
}

.history-panel-toggle::after {
    content: 'History';
    font-size: 12px;
    font-weight: 500;
}

@media (max-width: 768px) {
    .history-panel {
        width: 100%;
    }

    .history-panel-toggle {
        right: 20px;
        bottom: 120px;
        top: auto;
    }
}

@media (min-width: 769px) and (max-width: 1200px) {
    .history-panel {
        width: 280px;
    }
}

.sticky-downloads-bar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: auto !important;
    background: var(--bg-card) !important;
    backdrop-filter: blur(10px) !important;
    z-index: 9999 !important;
    padding: var(--space-2) 0 !important;
    display: none !important;
    justify-content: center !important;
    border-top: 1px solid var(--primary-2) !important;
    box-shadow: var(--shadow-lg) !important;
    transform: none !important;
    margin: 0 !important;
    max-height: none !important;
    min-height: 40px !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

.sticky-downloads-bar.visible {
    display: flex !important;
}

.download-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    max-width: 1400px;
    margin: 0 auto;
    gap: 10px;
}

.download-buttons-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.download-option-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    background: var(--bg-surface-alt);
    color: var(--primary);
    font-weight: 500;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.download-option-btn:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--text-primary);
}

.download-option-btn i {
    font-size: 1rem;
}

.download-option-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

@media (min-width: 769px) and (max-width: 1200px) {
    .feature-panel {
        width: 280px;
    }

    .feature-card {
        padding: 20px;
        min-height: 150px;
    }

    .feature-icon {
        width: 55px;
        height: 55px;
        font-size: 24px;
    }
}

.credits-bar a {
    color: var(--primary-2);
    font-weight: 500;
    text-decoration: none;
}

.credits-bar a:hover {
    text-decoration: underline;
}

.websocket-panel {
    position: fixed;
    top: 40px;
    left: 0;
    width: 300px;
    height: auto;
    max-height: calc(100vh - 80px);
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: var(--shadow-xl);
    overflow-y: auto;
}

.websocket-panel.open {
    transform: translateX(0);
}

.websocket-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-color);
}

.websocket-panel-header h3 {
    margin: 0;
    font-size: var(--font-size-xl);
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.websocket-panel-header h3 i {
    margin-right: var(--space-3);
    color: var(--primary);
}

.websocket-panel-actions {
    display: flex;
}

.websocket-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.websocket-action-btn:hover {
    background: var(--primary-light);
    color: var(--text-primary);
}

.websocket-status {
    padding: 15px;
    overflow-y: auto;
}

.status-item {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    font-size: 0.9rem;
    position: relative;
}

.status-label {
    color: var(--text-secondary);
    margin-right: var(--space-3);
    width: 130px;
    flex-shrink: 0;
}

.status-value {
    color: var(--text-primary);
    font-weight: 500;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    margin-left: var(--space-3);
    background-color: var(--gray-500);
}

.status-indicator.connected {
    background-color: var(--primary-2);
    box-shadow: 0 0 10px var(--primary-light);
}

.status-indicator.connecting {
    background-color: var(--warning);
    box-shadow: 0 0 10px var(--warning-bg);
}

.status-indicator.disconnected {
    background-color: var(--danger);
    box-shadow: 0 0 10px var(--error-bg);
}

.status-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-4) 0 var(--space-5);
}

@media (max-width: 768px) {
    .websocket-panel {
        width: 100%;
    }

    .websocket-panel-toggle-btn {
        left: 20px;
        top: 80px;
        width: 50px;
        height: 50px;
    }

    .websocket-panel-toggle-btn i {
        font-size: 22px;
    }
}

@media (max-width: 768px) {
    .sticky-downloads-bar .credits-content {
        flex-direction: column;
        padding: 5px 10px;
    }

    .sticky-downloads-bar p {
        margin-bottom: 5px;
        text-align: center;
    }

    .download-buttons-container {
        flex-wrap: wrap;
        justify-content: center;
    }

    .download-option-btn {
        margin: 2px;
        font-size: 0.8rem;
        padding: 4px 10px;
    }
}

.chat-container {
    margin-top: 40px;
    padding: 20px;
    border-radius: var(--radius-lg);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.chat-messages {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    padding: 15px;
    border-radius: var(--radius-md);
    background-color: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-surface-alt);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 10px;
}

.chat-message {
    margin-bottom: 15px;
    padding: 12px 18px;
    border-radius: 10px;
    max-width: 80%;
    position: relative;
}

.user-message {
    background-color: var(--primary);
    color: var(--gray-50);
    margin-left: auto;
    border-bottom-right-radius: 0;
}

.ai-message {
    background-color: var(--bg-surface-alt);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    margin-right: auto;
    border-bottom-left-radius: 0;
}

.chat-input-container {
    display: flex;
    gap: 10px;
}

.chat-input {
    flex-grow: 1;
    border-radius: var(--radius-full);
    padding: var(--space-3) var(--space-4);
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-weight: 400;
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-input:focus {
    background-color: var(--bg-surface-alt);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    color: var(--text-primary);
    font-weight: 500;
}

.chat-timestamp {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
    text-align: right;
}

#sendChatBtn {
    border-radius: 20px;
    padding: 10px 20px;
}

.chat-loading {
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background-color: var(--text-primary);
    opacity: 0.7;
    animation: dot-pulse 1.5s infinite;
}

.chat-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dot-pulse {

    0%,
    100% {
        transform: scale(0.7);
        opacity: 0.5;
    }

    50% {
        transform: scale(1);
        opacity: 1;
    }
}

.highlight-glow-download-button {
    box-shadow: 0 0 15px var(--primary-light), 0 0 25px var(--primary-light) !important;
    transform: translateY(-2px);
    transition: all 0.3s ease;
    border-color: var(--primary) !important;
}

.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-surface-alt);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.report-action-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-weight: 500;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: 1px solid var(--border-color);
}

.report-action-btn:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--text-primary);
    border-color: var(--primary);
}

.report-action-btn i {
    font-size: var(--font-size-base);
    color: var(--primary);
}

.report-action-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.expand-button {
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    padding: var(--space-1);
    margin-right: 0;
    margin-left: auto;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    position: absolute;
    right: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
}

.expand-button:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.expand-button:focus {
    outline: none;
}

.expanded-view {
    --modal-top: 50%;
    --modal-height: 85vh;

    position: fixed !important;
    top: var(--modal-top) !important;
    left: 50% !important;
    height: var(--modal-height) !important;
    width: 90vw !important;
    max-width: 1200px !important;
    transform: translate(-50%, -50%) !important;
    z-index: 9000 !important;
    margin: 0 !important;
    border-radius: var(--radius-md) !important;
    padding: var(--space-5) !important;
    overflow-y: auto !important;
    background-color: var(--bg-card) !important;
    box-shadow: var(--shadow-xl) !important;
    border: 1px solid var(--border-color) !important;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

@keyframes modalAppear {
    from {
        opacity: 0.8;
        transform: translateX(-50%) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}

.research-output-container h2,
.report-container h2,
#chatContainer h2 {
    position: relative;
    padding-right: 50px;
    display: flex;
    align-items: center;

}

#reportContainer,
#output,
#chatMessages {
    transition: all 0.3s ease;
}

.report-container,
.research-output-container,
#chatContainer {
    transition: all 0.3s ease;
    position: relative;
}

.expand-button {
    z-index: 100;
    top: 0;
    right: 0;
    transform: none;
    margin: 10px;
    position: absolute;
}

@media (max-width: 768px) {
    .expanded-view {
        top: 50% !important;
        left: 50% !important;
        width: 95vw !important;
        height: 90vh !important;
        transform: translate(-50%, -50%) !important;
        border-radius: 8px !important;
        padding: 15px !important;
    }

    .expanded-view #output,
    .expanded-view #reportContainer,
    .expanded-view #chatMessages {
        max-height: 70vh !important;
        width: 100% !important;
        padding: 15px !important;
    }
}

#voiceInputBtn {
    margin-right: var(--space-2);
    border-radius: var(--radius-full);
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--warning) !important;
    border: 1px solid var(--warning-text) !important;
    padding: var(--space-3);
    font-size: var(--font-size-lg);
    line-height: 1;
    transition: all 0.2s ease;
}

#voiceInputBtn i {
    font-size: var(--font-size-xl);
    color: var(--gray-50);
    transition: all 0.2s ease;
}

#voiceInputBtn:hover {
    background: var(--warning-text) !important;
    border-color: var(--warning) !important;
}

#voiceInputBtn.listening {
    background: var(--error-bg) !important;
    border-color: var(--danger) !important;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(220, 53, 69, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    }
}

.toast-notification {
    position: fixed;
    bottom: var(--space-5);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    font-size: var(--font-size-sm);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    border-left: 3px solid var(--primary);
}

.toast-notification.show {
    opacity: 1;
    transform: translate(-50%, -10px);
}

.history-actions-container {
    display: flex;
    gap: 8px;
    margin-left: 10px;
}

.history-action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    font-size: var(--font-size-sm);
}

.history-action-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: translateY(-2px);
}

#historyFileInput {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

#task {
    min-height: 60px;
    overflow-y: hidden;
    resize: none;
}

.expanded-view h2 {
    position: relative;
    padding-right: 40px;
    margin-bottom: 20px !important;
}

.expanded-view .expand-button i {
    /* transform: rotate(180deg); */
    /* Removed to prevent icon confusion */
}

.expanded-view #reportContainer {
    padding: 20px !important;
    font-size: 1.1rem !important;
    max-height: 75vh !important;
    overflow-y: auto !important;
    width: 100% !important;
    border: none !important;
}

.expanded-view #chatMessages {
    max-height: 60vh !important;
    overflow-y: auto !important;
    width: 100% !important;
}

.expanded-view #output {
    height: 60vh !important;
    max-height: 60vh !important;
    overflow-y: auto !important;
    width: 100% !important;
    border: none !important;
    background-color: transparent !important;
}

.expanded-view {
    animation: modalAppear 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@media (max-width: 768px) {
    .expanded-view {
        top: var(--modal-top) !important;
        left: 50% !important;
        height: var(--modal-height) !important;
        width: 95vw !important;
        transform: translateX(-50%) !important;
        border-radius: 8px !important;
        padding: 15px !important;
    }

    .expanded-view #output,
    .expanded-view #reportContainer,
    .expanded-view #chatMessages {
        width: 100% !important;
        padding: 15px !important;
    }
}

.landing .btn {
    display: block;
    margin: 2rem auto;
    max-width: 220px;
}

#researchForm input[type="submit"] {
    display: block;
    margin: var(--space-8) auto;
    font-size: var(--font-size-xl);
    padding: var(--space-4) var(--space-10);
    min-width: 220px;
    box-shadow: var(--shadow-md);
}

#researchForm input[type="submit"]:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

@media (max-width: 768px) {

    .btn-primary,
    .btn-secondary {
        font-size: 1rem;
        padding: 10px 25px;
        min-width: 160px;
    }

    #researchForm input[type="submit"] {
        padding: 12px 30px;
        font-size: 1.1rem;
        min-width: 180px;
    }
}

/* Image Dialog Styles */
.image-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    /* Darker backdrop for better focus */
    display: flex;
    flex-direction: column;
    /* Align button below image */
    justify-content: center;
    align-items: center;
    z-index: 10000;
    /* Ensure it's on top of everything */
    padding: 20px;
    /* Add some padding around */
    box-sizing: border-box;
    /* Include padding in width/height */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.image-dialog.visible {
    opacity: 1;
    visibility: visible;
}

.image-dialog img {
    max-width: 90%;
    /* Responsive image width */
    max-height: 80%;
    /* Responsive image height */
    object-fit: contain;
    /* Ensure image aspect ratio is maintained */
    border-radius: 8px;
    /* Slightly rounded corners for the image */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    /* Subtle shadow for depth */
}

.image-dialog .close-btn {
    background: var(--gradient-primary-90);
    color: var(--gray-50);
    border: none;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-top: var(--space-5);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.image-dialog .save-btn {
    background: linear-gradient(to right, var(--info), var(--primary));
    color: var(--gray-50);
    border: none;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-top: var(--space-3);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.image-dialog .save-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.image-dialog .close-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Ensure the dialog is not selectable when hidden */
.image-dialog:not(.visible) {
    pointer-events: none;
}

/* MCP Configuration Styles */
.mcp-section {
    margin-bottom: 1rem;
}

.mcp-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.mcp-header label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin: 0;
}

.mcp-toggle {
    margin: 0;
}

.mcp-info-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
}

.mcp-info-btn:hover {
    color: var(--primary);
    background-color: var(--primary-light);
}

.mcp-config-section {
    margin-top: var(--space-4);
    padding: var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-surface-alt);
}

.mcp-presets {
    margin-bottom: 10px;
}

.preset-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 5px;
}

.preset-btn {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    background: var(--bg-card);
}

.preset-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.preset-btn i {
    font-size: 0.9em;
}

.mcp-config-group {
    margin-bottom: 10px;
}

.mcp-config-textarea {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    line-height: 1.4;
    resize: vertical;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    background-color: var(--bg-surface);
}

.mcp-config-textarea:focus {
    border-color: var(--primary);
    background-color: var(--bg-card);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.mcp-config-textarea.invalid {
    border-color: var(--danger);
    background-color: var(--error-bg);
}

.mcp-config-textarea.valid {
    border-color: var(--success);
    background-color: var(--success-bg);
}

.mcp-config-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    margin-bottom: 5px;
}

.mcp-status-text {
    font-size: 0.875rem;
    font-weight: 500;
}

.mcp-status-text.valid {
    color: var(--success);
}

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

#mcpFormatBtn {
    font-size: 0.8rem;
    padding: 4px 8px;
}

#mcpExampleLink {
    color: var(--primary);
    text-decoration: none;
}

#mcpExampleLink:hover {
    text-decoration: underline;
}

/* ========================================
   DARK THEME SPECIFIC OVERRIDES
   ======================================== */
html[data-theme='dark'] body.agent-page {
    color: var(--text-primary);
    background-color: var(--bg-body);
    background-image: none;
}

html[data-theme='dark'] .container {
    background-color: var(--bg-card);
    box-shadow: var(--shadow-lg);
}

html[data-theme='dark'] input,
html[data-theme='dark'] select,
html[data-theme='dark'] #output,
html[data-theme='dark'] #reportContainer {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-color);
}

html[data-theme='dark'] input:hover,
html[data-theme='dark'] input:focus,
html[data-theme='dark'] select:hover,
html[data-theme='dark'] select:focus {
    background-color: var(--bg-surface-alt);
    border-color: var(--border-color-hover);
}

html[data-theme='dark'] .margin-div {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

html[data-theme='dark'] .research-output-container h2,
html[data-theme='dark'] .report-container h2 {
    color: var(--text-primary);
}

html[data-theme='dark'] .agent_response {
    background-color: var(--bg-surface-alt);
    color: var(--text-primary);
}

/* MCP Info Modal */
.mcp-info-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mcp-info-modal.visible {
    opacity: 1;
    visibility: visible;
}

.mcp-info-content {
    background: rgba(0, 0, 0, 0.5);
    padding: 25px;
    border-radius: 12px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    margin: 20px;
}

.mcp-info-close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    background: none;
    border: none;
    font-size: var(--font-size-2xl);
    cursor: pointer;
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
}

.mcp-info-close:hover {
    background-color: var(--bg-surface-alt);
    color: var(--danger);
}

.mcp-info-content h3 {
    margin-top: 0;
    color: var(--text-primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: var(--space-3);
}

.mcp-info-content p {
    line-height: 1.6;
    color: var(--text-secondary);
}

.mcp-info-content ul {
    padding-left: 20px;
    line-height: 1.6;
}

.mcp-info-content li {
    margin-bottom: 8px;
}

.mcp-info-content .highlight {
    color: var(--primary);
    font-weight: 600;
}

.avatar {
        width: 80px;
        height: 80px;
        border-radius: 50%;
    }

    .agent-name {
        text-align: center;
    }

    .agent-item {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .agent-choices {
        display: none;
    }

    .btn-show {
        display: none;
    }

    /* Icon button style for inline buttons */
    .icon-button {
        background: none;
        border: none;
        cursor: pointer;
        padding: 5px;
        margin-left: 5px;
        border-radius: 4px;
        transition: background-color 0.2s, color 0.2s;
    }

    .icon-button:hover {
        background-color: var(--primary-light);
        /* Placeholder, adjust in styles.css */
    }

    /* Ensure buttons are properly aligned in headings */
    h2 .icon-button,
    h2 .expand-button {
        vertical-align: middle;
        font-size: 0.8em;
    }

    /* New navigation buttons in the top-right corner */
    .nav-buttons {
        position: fixed;
        top: 86px;
        right: 20px;
        display: flex;
        gap: 10px;
        z-index: 100;
    }

    /* Stili per il modale della galleria */
    .gallery-modal {
        display: none;
        position: fixed;
        z-index: 1050;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        overflow: auto;
        background-color: rgba(0, 0, 0, 0.8);
    }

    .gallery-modal-content {
        background-color: var(--bg-card);
        margin: 5% auto;
        padding: var(--space-5);
        border: 1px solid var(--border-color);
        width: 90%;
        max-width: 1400px;
        border-radius: var(--radius-md);
        display: flex;
        flex-direction: column;
        height: 90vh;
    }

    .gallery-modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: var(--space-4);
    }

    .gallery-modal-close {
        color: var(--text-muted);
        font-size: var(--font-size-3xl);
        font-weight: bold;
        background: none;
        border: none;
        cursor: pointer;
    }

    .gallery-modal-close:hover,
    .gallery-modal-close:focus {
        color: var(--text-primary);
        text-decoration: none;
        cursor: pointer;
    }

    .gallery-modal-body {
        flex-grow: 1;
        overflow-y: auto;
        padding-top: 1rem;
    }

    /* Stili per la galleria immagini (copiati da image_generator.html) */
    .gallery-container {
        position: relative;
        padding: 10px 0;
        margin-top: 15px;
        overflow: hidden;
    }

    .gallery {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 15px;
        padding: 15px;
        margin: 0;
        max-height: 100%;
        overflow-y: auto;
        scroll-behavior: smooth;
    }

    .gallery-item {
        width: 100%;
        height: 180px;
        border-radius: var(--radius-md);
        position: relative;
        overflow: hidden;
        cursor: pointer;
        box-shadow: var(--shadow-sm);
        background-color: var(--bg-surface-alt);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .gallery-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    }

    .gallery-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.3s;
    }

    .gallery-item-info {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: var(--space-2);
        background-color: rgba(0, 0, 0, 0.6);
        color: var(--gray-50);
        font-size: var(--font-size-sm);
        opacity: 0;
        transition: opacity 0.3s;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .gallery-item:hover .gallery-item-info {
        opacity: 1;
    }

    .gallery-loading {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 200px;
        color: var(--text-muted);
        font-style: italic;
        grid-column: 1 / -1;
    }

    .gallery-item-actions {
        position: absolute;
        top: 8px;
        right: 8px;
        display: flex;
        gap: 8px;
        opacity: 0;
        transition: opacity 0.2s ease-in-out;
        z-index: 10;
    }

    .gallery-item:hover .gallery-item-actions {
        opacity: 1;
    }

    .gallery-action-btn {
        background: rgba(0, 0, 0, 0.6);
        color: var(--gray-50);
        border: none;
        border-radius: var(--radius-full);
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        text-decoration: none;
        font-size: var(--font-size-sm);
    }

    .gallery-action-btn:hover {
        background: rgba(0, 0, 0, 0.8);
        color: var(--gray-50);
    }

    .gallery-action-btn.delete-btn:hover {
        background-color: var(--danger);
    }



@media (max-width: 768px) {
    .preset-buttons {
        flex-direction: column;
    }

    .preset-btn {
        justify-content: center;
    }

    .mcp-info-content {
        margin: 10px;
        padding: 20px;
    }

    .mcp-config-status {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .avatar {
        width: 80px;
        height: 80px;
        border-radius: 50%;
    }

    .agent-name {
        text-align: center;
    }

    .agent-item {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .agent-choices {
        display: none;
    }

    .btn-show {
        display: none;
    }

    /* Icon button style for inline buttons */
    .icon-button {
        background: none;
        border: none;
        cursor: pointer;
        padding: 5px;
        margin-left: 5px;
        border-radius: 4px;
        transition: background-color 0.2s, color 0.2s;
    }

    .icon-button:hover {
        background-color: var(--primary-light);
        /* Placeholder, adjust in styles.css */
    }

    /* Ensure buttons are properly aligned in headings */
    h2 .icon-button,
    h2 .expand-button {
        vertical-align: middle;
        font-size: 0.8em;
    }

    /* New navigation buttons in the top-right corner */
    .nav-buttons {
        position: fixed;
        top: 100px;
        right: 90px;
        display: flex;
        gap: 10px;
        z-index: 100;
    }

    /* Stili per il modale della galleria */
    .gallery-modal {
        display: none;
        position: fixed;
        z-index: 1050;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        overflow: auto;
        background-color: rgba(0, 0, 0, 0.8);
    }

    .gallery-modal-content {
        background-color: var(--bg-card);
        margin: 5% auto;
        padding: var(--space-5);
        border: 1px solid var(--border-color);
        width: 90%;
        max-width: 1400px;
        border-radius: var(--radius-md);
        display: flex;
        flex-direction: column;
        height: 90vh;
    }

    .gallery-modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: var(--space-4);
    }

    .gallery-modal-close {
        color: var(--text-muted);
        font-size: var(--font-size-3xl);
        font-weight: bold;
        background: none;
        border: none;
        cursor: pointer;
    }

    .gallery-modal-close:hover,
    .gallery-modal-close:focus {
        color: var(--text-primary);
        text-decoration: none;
        cursor: pointer;
    }

    .gallery-modal-body {
        flex-grow: 1;
        overflow-y: auto;
        padding-top: 1rem;
    }

    /* Stili per la galleria immagini (copiati da image_generator.html) */
    .gallery-container {
        position: relative;
        padding: 10px 0;
        margin-top: 15px;
        overflow: hidden;
    }

    .gallery {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 15px;
        padding: 15px;
        margin: 0;
        max-height: 100%;
        overflow-y: auto;
        scroll-behavior: smooth;
    }

    .gallery-item {
        width: 100%;
        height: 180px;
        border-radius: var(--radius-md);
        position: relative;
        overflow: hidden;
        cursor: pointer;
        box-shadow: var(--shadow-sm);
        background-color: var(--bg-surface-alt);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .gallery-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    }

    .gallery-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.3s;
    }

    .gallery-item-info {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: var(--space-2);
        background-color: rgba(0, 0, 0, 0.6);
        color: var(--gray-50);
        font-size: var(--font-size-sm);
        opacity: 0;
        transition: opacity 0.3s;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .gallery-item:hover .gallery-item-info {
        opacity: 1;
    }

    .gallery-loading {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 200px;
        color: var(--text-muted);
        font-style: italic;
        grid-column: 1 / -1;
    }

    .gallery-item-actions {
        position: absolute;
        top: 8px;
        right: 8px;
        display: flex;
        gap: 8px;
        opacity: 0;
        transition: opacity 0.2s ease-in-out;
        z-index: 10;
    }

    .gallery-item:hover .gallery-item-actions {
        opacity: 1;
    }

    .gallery-action-btn {
        background: rgba(0, 0, 0, 0.6);
        color: white;
        border: none;
        border-radius: 50%;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        text-decoration: none;
        font-size: 14px;
    }



    .gallery-action-btn:hover {
        background: rgba(0, 0, 0, 0.8);
        color: white;
    }

    .gallery-action-btn.delete-btn:hover {
        background-color: var(--danger);
    }
}
