:root {
    --rsa-bg: #0A192F;
    --rsa-card: #112240;
    --rsa-input-bg: #172A45;
    --rsa-border: #233554;
    --rsa-text-main: #E6F1FF;
    --rsa-text-muted: #8892B0;
    --rsa-accent: #64FFDA;
    --rsa-gold: #E5C365;
    --rsa-green: #00E676;
    --rsa-blue: #29B6F6;
    --rsa-orange: #FF9100;
    --rsa-red: #FF1744;
    --chat-bg: #0D1626;
    --chat-bubble-bot: #162032;
}

/* --- General --- */
.rsa-wrapper {
    background-color: var(--rsa-bg);
    color: var(--rsa-text-main);
    padding: 30px;
    border-radius: 16px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    max-width: 1200px;
    width: 95%;
    margin: 20px auto;
    direction: rtl;
    line-height: 1.6;
    box-sizing: border-box;
}
.rsa-wrapper * { box-sizing: border-box; }

.rsa-header { text-align: center; margin-bottom: 30px; border-bottom: 1px solid var(--rsa-border); padding-bottom: 20px; }
.rsa-header h2 { color: #FFFFFF; margin: 0 0 10px; font-size: 2rem; font-weight: 700; }
.rsa-header p { color: var(--rsa-text-muted); font-size: 1rem; }

/* Layout */
.rsa-container { display: grid; grid-template-columns: 350px 1fr; gap: 30px; }
.rsa-sidebar { background: var(--rsa-card); padding: 25px; border-radius: 12px; border: 1px solid var(--rsa-border); }

/* Inputs */
.rsa-input-group { margin-bottom: 20px; }
.rsa-input-group label { display: block; margin-bottom: 8px; font-size: 0.95rem; color: var(--rsa-text-main); font-weight: 500; }
.rsa-input-group input {
    width: 100%; padding: 12px; background: var(--rsa-input-bg);
    border: 1px solid var(--rsa-border); color: #FFF; border-radius: 8px; font-size: 1rem;
    transition: 0.3s;
}
.rsa-input-group input:focus { border-color: var(--rsa-accent); outline: none; }

/* Select Box (محسن وكبير) */
.rsa-select-wrapper { position: relative; width: 100%; }
.rsa-risk-select {
    width: 100%; height: 55px; padding: 0 20px;
    background-color: var(--rsa-input-bg);
    border: 2px solid var(--rsa-border); color: #FFF;
    border-radius: 10px; font-size: 1.1rem; cursor: pointer;
    appearance: none; text-align: center; text-align-last: center;
    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='%2364FFDA' 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: left 15px center; background-size: 18px;
}
.rsa-risk-select:focus { border-color: var(--rsa-accent); }

/* Main Button */
.rsa-btn-primary {
    width: 100%; background: var(--rsa-accent); color: #0A192F;
    border: none; padding: 15px; border-radius: 8px; font-weight: 800; font-size: 1.1rem;
    cursor: pointer; margin-top: 10px; transition: 0.2s;
}
.rsa-btn-primary:hover { transform: translateY(-2px); }

/* Cards */
.rsa-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 25px; }
.rsa-card { background: var(--rsa-card); padding: 20px; border-radius: 12px; text-align: center; border-top: 4px solid transparent; }
.rsa-card.conservative { border-color: var(--rsa-green); }
.rsa-card.realistic { border-color: var(--rsa-blue); }
.rsa-card.optimistic { border-color: var(--rsa-orange); }

/* White Titles for Scenarios */
.rsa-card h4 { margin: 0 0 10px; font-size: 1rem; color: #FFFFFF !important; font-weight: 600; }
.rsa-amount { font-size: 1.5rem; font-weight: 800; color: #FFF; margin: 10px 0; direction: ltr; }
.rsa-card small { font-size: 0.85rem; color: var(--rsa-text-muted); }

/* Chart & Panel */
.rsa-chart-container { background: var(--rsa-card); padding: 15px; border-radius: 12px; height: 350px; margin-bottom: 25px; border: 1px solid var(--rsa-border); }
.rsa-risk-panel { background: #13274A; padding: 25px; border-radius: 12px; border: 1px solid var(--rsa-border); }

/* White Title for Risk Panel */
.rsa-panel-header h4 { color: #FFFFFF !important; font-size: 1.2rem; margin-bottom: 15px; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 10px; }

.rsa-risk-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.rsa-risk-grid strong { font-size: 1.2rem; color: #FFF; display: block; margin-top: 5px; direction: ltr; }
.text-danger { color: var(--rsa-red); }
.text-success { color: var(--rsa-green); }

/* Floating Actions */
.rsa-floating-actions {
    display: flex; flex-direction: column; align-items: center; gap: 15px;
    margin-top: 30px; border-top: 1px solid var(--rsa-border); padding-top: 25px;
}
.rsa-btn-float {
    background: #FFF; color: #0A192F; border: none; padding: 12px 30px;
    border-radius: 50px; font-weight: bold; cursor: pointer; display: flex; align-items: center; gap: 10px; font-size: 1rem;
}
.rsa-btn-float:hover:not(:disabled) { background: var(--rsa-accent); }

/* Transparent Ghost Button */
.rsa-btn-ghost {
    background: transparent; border: 1px solid rgba(255, 255, 255, 0.3); color: rgba(255, 255, 255, 0.8);
    padding: 8px 20px; border-radius: 50px; font-size: 0.9rem; cursor: pointer;
}
.rsa-btn-ghost:hover { border-color: #FFF; color: #FFF; background: rgba(255,255,255,0.05); }

/* --- Chat Modal --- */
.rsa-modal { display: none; position: fixed; z-index: 9999; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); backdrop-filter: blur(5px); }

.rsa-modal-content.chat-layout {
    background-color: var(--chat-bg);
    border: 1px solid var(--rsa-border);
    margin: 3vh auto; width: 95%; max-width: 500px; height: 90vh;
    border-radius: 24px; display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 20px 80px rgba(0,0,0,0.8);
}
.rsa-chat-header { padding: 15px; border-bottom: 1px solid var(--rsa-border); display: flex; justify-content: space-between; align-items: center; }
.rsa-advisor-titles h3 { color: #FFF; margin: 0; font-size: 1rem; }
.rsa-online-dot { width: 8px; height: 8px; background: var(--rsa-green); border-radius: 50%; box-shadow: 0 0 10px var(--rsa-green); }

.rsa-chat-history { flex: 1; padding: 20px; overflow-y: auto; background: var(--chat-bg); display: flex; flex-direction: column; gap: 20px; }
.rsa-msg { max-width: 85%; padding: 12px 16px; border-radius: 12px; font-size: 0.95rem; line-height: 1.5; color: #EEE; }
.bot-msg { background: var(--chat-bubble-bot); border-right: 4px solid var(--rsa-gold); align-self: flex-start; }
.bot-msg ul { padding-right: 20px; margin: 10px 0; }
.bot-msg li { margin-bottom: 5px; list-style-type: disc; }
.bot-msg strong { color: var(--rsa-gold); }
.user-msg { background: transparent; border: 1px solid var(--rsa-border); align-self: flex-end; }

.rsa-chat-input-area { padding: 15px; background: var(--chat-bg); display: flex; gap: 10px; border-top: 1px solid var(--rsa-border); align-items: center; }
.rsa-chat-input-area input {
    flex: 1; background: #111b2b; border: 1px solid var(--rsa-border); padding: 14px;
    border-radius: 12px; color: #FFF; outline: none; font-size: 1rem;
}
.rsa-chat-input-area input:focus { border-color: var(--rsa-gold); }

/* Large Send Button */
#rsa-send-btn {
    background: var(--rsa-gold); width: 30px; height: 30px;
    border-radius: 25px; border: none; display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
}
#rsa-send-btn svg { width: 30px; height: 30px; transform: rotate(-45deg); }

/* Legal Modal */
.legal-content {
    background: var(--rsa-card); border: 1px solid var(--rsa-border);
    padding: 25px; margin-top: 15vh; border-radius: 16px; max-width: 600px;
}
.rsa-legal-title { color: #FFFFFF !important; font-size: 1.3rem; border-bottom: 1px solid var(--rsa-border); padding-bottom: 10px; margin-bottom: 15px; }
.rsa-legal-body p { color: #E6F1FF; }
.rsa-close-legal, .rsa-close { color: #8892B0; font-size: 28px; cursor: pointer; }

/* Breakpoints */
@media only screen and (max-width: 900px) {
    .rsa-container { grid-template-columns: 1fr; gap: 25px; }
    .rsa-sidebar { width: 100%; }
}
@media only screen and (max-width: 600px) {
    .rsa-wrapper { padding: 15px; width: 100%; margin: 0; border-radius: 0; box-shadow: none; }
    .rsa-cards, .rsa-risk-grid { grid-template-columns: 1fr; }
    
    /* Pop-up Card for Mobile */
    .rsa-modal-content.chat-layout { 
        width: 95%; height: 80vh; margin: 10vh auto; 
        border-radius: 20px; max-width: 100%;
        box-shadow: 0 10px 50px rgba(0,0,0,0.9);
    }
    .rsa-chat-input-area { padding: 10px; }
}

.typing-indicator { display: flex; gap: 5px; }
.typing-dot {
    width: 8px; height: 8px; background-color: var(--rsa-gold); border-radius: 50%;
    animation: typing-wave 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing-wave { 0%, 80%, 100% { transform: scale(0); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }