File size: 2,262 Bytes
52e48a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
def get_theme_colors(dm):
    return {
        "BG": "#0f1620" if dm else "#f5f5f5",
        "PANEL_BG": "#1c2330" if dm else "#ffffff",
        "TEXT": "#e3e8f1" if dm else "#1a1a1a",
        "ACCENT": "#ff5252",
        "BORDER": "#2a3240" if dm else "#dddddd",
        "SHADOW": "rgba(0,0,0,0.3)" if dm else "rgba(0,0,0,0.1)",
        "ACE_THEME": "monokai" if dm else "chrome",
    }

def inject_global_css(colors):
    import streamlit as st
    st.markdown(f"""
    <style>
      .stApp {{ background-color: {colors["BG"]}; color: {colors["TEXT"]}; }}
      [data-testid="stSidebar"] {{ background-color: {colors["PANEL_BG"]} !important; }}
      .ace_editor, .ace_scroller {{
          background: {colors["PANEL_BG"]} !important;
          box-shadow: 0 4px 8px {colors["SHADOW"]} !important;
          border-radius: 8px !important;
      }}
      textarea, input, .stTextArea textarea {{
          background: {colors["PANEL_BG"]} !important;
          color: {colors["TEXT"]} !important;
          border: 1px solid {colors["BORDER"]} !important;
          border-radius: 4px !important;
      }}
      button, .stDownloadButton > button {{
          background-color: {colors["ACCENT"]} !important;
          color: #fff !important;
          border-radius: 6px !important;
          transition: transform 0.1s;
      }}
      button:hover {{ transform: scale(1.02) !important; }}
      .chat-container {{
          background: {colors["PANEL_BG"]} !important;
          border: 1px solid {colors["BORDER"]} !important;
          border-radius: 8px !important;
          padding: 1rem;
          max-height: 480px;
          overflow-y: auto;
      }}
      .chat-message {{ margin-bottom: 1rem; padding: 0.75rem 1rem; border-radius: 12px; }}
      .user-message {{ background: rgba(100,149,237,0.2); align-self: flex-end; }}
      .bot-message {{ background: rgba(200,200,200,0.2); align-self: flex-start; }}
      pre code {{
          display: block;
          padding: 0.5rem;
          background: rgba(0,0,0,0.1);
          border-radius: 4px;
          overflow-x: auto;
      }}
      label[data-testid="stMarkdownContainer"] > div > div {{
          color: {colors["TEXT"]} !important;
      }}
    </style>
    """, unsafe_allow_html=True)