
/* Hide Gradio branding/footer across versions (4.x / 6.x) */
footer,
#footer,
.footer,
.gradio-footer,
[data-testid="footer"],
.built-with-gradio,
.built-with-gradio-footer {
    display: none !important;
}

/* Base */
.gradio-container {
    background: var(--zsy-bg);
    color: var(--zsy-text);
}
html, body {
    background: var(--zsy-bg) !important;
}

:root {
    --zsy-radius: 14px;
    /* Keep our own palette so Gradio 4.x / 6.x render consistently */
    --zsy-bg: #f6f7fb;
    --zsy-panel: #ffffff;
    --zsy-text: rgba(2, 6, 23, 0.92);
    --zsy-muted: rgba(2, 6, 23, 0.60);
    --zsy-border: rgba(15, 23, 42, 0.10);
    --zsy-shadow: 0 10px 24px rgba(2, 6, 23, 0.06);
    --zsy-input-bg: #ffffff;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --zsy-bg: #0b1220;
        --zsy-panel: rgba(15, 23, 42, 0.86);
        --zsy-text: rgba(248, 250, 252, 0.95);
        --zsy-muted: rgba(226, 232, 240, 0.78);
        --zsy-border: rgba(148, 163, 184, 0.16);
        --zsy-shadow: 0 18px 38px rgba(0, 0, 0, 0.35);
        --zsy-input-bg: rgba(15, 23, 42, 0.72);
        color-scheme: dark;
    }
}

/* Content width */
#login_page, #chat_interface {
    max-width: 1200px;
    margin: 0 auto;
    padding: 18px 14px;
}
#login_page { max-width: 520px; }

/* Card/panel (use custom class to avoid conflicts with Gradio's built-in .panel styles) */
.zsy-panel {
    background: var(--zsy-panel);
    border: 1px solid var(--zsy-border);
    border-radius: var(--zsy-radius);
    box-shadow: var(--zsy-shadow);
    padding: 14px;
    color: var(--zsy-text);
}

/* Markdown readability (Gradio uses .prose) */
.prose, .prose p, .prose li, .prose td, .prose th {
    color: var(--zsy-text) !important;
}
.prose strong { color: var(--zsy-text) !important; }
.prose a { color: #6366f1 !important; }

/* Inputs/placeholder in dark mode */
input, textarea { color: var(--zsy-text) !important; }
::placeholder { color: rgba(148, 163, 184, 0.75) !important; }
@media (prefers-color-scheme: dark) {
    ::placeholder { color: rgba(226, 232, 240, 0.60) !important; }
}

/* Avoid overly-dim disabled fields (e.g., status textbox) */
input:disabled, textarea:disabled {
    opacity: 1 !important;
    color: var(--zsy-muted) !important;
    -webkit-text-fill-color: var(--zsy-muted) !important;
}

/* Buttons: force a consistent primary/secondary look across Gradio versions */
button.primary,
.primary button,
.gr-button-primary button,
.gr-button-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%) !important;
    border: 1px solid rgba(79, 70, 229, 0.38) !important;
    color: #fff !important;
}
button.secondary,
.secondary button,
.gr-button-secondary button,
.gr-button-secondary {
    background: rgba(148, 163, 184, 0.10) !important;
    border: 1px solid var(--zsy-border) !important;
    color: var(--zsy-text) !important;
}

/* Login */
.login-wrap {
    min-height: calc(100vh - 40px);
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-box {
    padding: 28px !important;
}
.login-title { text-align: center; margin-bottom: 10px; }
.login-subtitle { text-align: center; color: var(--zsy-muted); margin-bottom: 18px; }
.login-input input {
    border-radius: 10px !important;
    padding: 10px 12px !important;
    border: 1px solid var(--zsy-border) !important;
    background: var(--zsy-input-bg) !important;
    color: var(--zsy-text) !important;
}
.login-input {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}
.login-input .wrap,
.login-input .container,
.login-input > .wrap,
.login-input > .container,
.login-input .form,
.login-input .block {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}
.login-input input:focus {
    border-color: rgba(79,70,229,0.45) !important;
    box-shadow: 0 0 0 4px rgba(79,70,229,0.14) !important;
}
.login-btn {
    border-radius: 10px !important;
    font-weight: 600 !important;
}
.login-btn button {
    width: 100%;
    border-radius: 12px !important;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%) !important;
    border: 1px solid rgba(79,70,229,0.38) !important;
    box-shadow: 0 10px 22px rgba(79,70,229,0.22) !important;
}
.login-btn button:hover {
    filter: brightness(0.98);
}
.login-status {
    margin-top: 10px;
    text-align: center;
    color: var(--zsy-muted);
    font-size: 0.95rem;
}
.login-status:empty { display: none; }

/* Top bar */
#topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 10px 0 12px 0;
}
#topbar_inner {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
#topbar_actions { justify-content: flex-end; gap: 10px; }
#topbar .prose h1, #topbar .prose h2, #topbar .prose h3 {
    margin: 0;
}

/* Main layout */
#mainrow { gap: 14px; align-items: stretch; }

/* Chat */
#chatbot { border-radius: 12px; }
#chatbot .wrap { border-radius: 12px; }
#chatbot .wrap {
    background: var(--zsy-panel) !important;
    border: 1px solid var(--zsy-border) !important;
}

/* Composer */
#composer { gap: 10px; align-items: flex-end; }
#composer textarea, #composer input {
    border-radius: 12px !important;
}

/* Make chatbot take more vertical space (best-effort across Gradio versions) */
#chatbot { height: calc(100vh - 250px) !important; }
@media (max-width: 860px) {
    #chatbot { height: calc(100vh - 300px) !important; }
}

/* Sidebar */
#sidebar .prose h3 { margin-top: 0; }
#sidebar { max-height: calc(100vh - 260px); overflow-y: auto; overflow-x: hidden; }
#file_drop { margin: 8px 0 10px 0; }
#file_drop .wrap {
    border-radius: 12px !important;
    border: 1px dashed var(--zsy-border) !important;
    background: rgba(148, 163, 184, 0.06) !important;
}
@media (prefers-color-scheme: dark) {
    #file_drop .wrap {
        background: rgba(148, 163, 184, 0.08) !important;
    }
}

/* Mobile: stack sidebar under chat */
@media (max-width: 860px) {
    #mainrow { flex-direction: column; }
    #sidebar { max-height: none; }
    #topbar .zsy-panel { flex-wrap: wrap; gap: 8px; }
    #login_page, #chat_interface { padding: 14px 10px; }
    #topbar_actions { justify-content: flex-start; }
}
@media (max-width: 520px) {
    #composer { flex-direction: column; }
    #topbar_inner { gap: 8px; }
    #topbar_actions { gap: 8px; }
}
