:root {
    --bg-main: #0B1F38; --bg-sidebar: #071526; --bg-card: #112A46; --bg-input: #0B1F38;
    --gold-primary: #D4AF37; --gold-hover: #E5C354; --gold-dim: rgba(212, 175, 55, 0.1);
    --text-white: #FFFFFF; --text-muted: #7A96B2; --border-color: rgba(255, 255, 255, 0.08);
    --danger-red: #E74C3C; --danger-bg: rgba(231, 76, 60, 0.1);
    --radius-lg: 16px; --radius-md: 10px; --radius-sm: 6px;
    --font-main: 'Cairo', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-main); background-color: var(--bg-main); color: var(--text-white); display: flex; height: 100vh; overflow: hidden; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-main); }
::-webkit-scrollbar-thumb { background: #1C3F60; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-primary); }

.sidebar { width: 280px; min-width: 280px; flex-shrink: 0; background: var(--bg-sidebar); display: flex; flex-direction: column; padding: 30px 15px; border-left: 1px solid var(--border-color); z-index: 10; }
.logo-container { text-align: center; margin-bottom: 40px; }
/* تنسيق صورة اللوجو الجديدة بخلفية بيضاء */
.logo-img { width: auto; max-width: 160px; height: 70px; margin: 0 auto 12px auto; display: block; background: transparent; background-color: transparent; padding: 0; border-radius: 0; border: none; box-shadow: none; object-fit: contain; }

.main-title { font-size: 1.2rem; font-weight: 800; color: var(--text-white); }
.sub-title { font-size: 0.75rem; color: var(--text-muted); margin-top: 5px; }
.nav-menu { flex-grow: 1; }
.nav-btn { background: transparent; color: var(--text-muted); border: none; width: 100%; text-align: right; padding: 14px 20px; margin-bottom: 8px; border-radius: var(--radius-md); cursor: pointer; font-size: 0.95rem; font-weight: 600; transition: all 0.3s ease; font-family: inherit; display: flex; align-items: center; gap: 15px; }
.nav-btn i { font-size: 1.1rem; width: 20px; text-align: center; }
.nav-btn:hover { color: var(--text-white); background: rgba(255,255,255,0.02); }
.nav-btn.active { background: var(--gold-primary); color: var(--bg-sidebar); font-weight: 800; }
.sidebar-footer { padding-top: 20px; border-top: 1px solid var(--border-color); }
.logout-btn { color: var(--danger-red); }
.logout-btn:hover { background: var(--danger-bg); }

.main-wrapper { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; }
.top-bar { height: 100px; display: flex; justify-content: space-between; align-items: center; padding: 0 40px; }
.page-header-info { text-align: right; }
.top-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 5px; }
.btn-outline-gold { background: transparent; color: var(--gold-primary); border: 1px solid var(--gold-primary); padding: 10px 20px; border-radius: var(--radius-md); font-family: inherit; font-weight: 700; cursor: pointer; transition: 0.3s; display: flex; gap: 8px; align-items: center; }
.btn-outline-gold:hover { background: var(--gold-dim); }
.top-bar-actions { display: flex; gap: 15px; }

.main-content { flex-grow: 1; padding: 0 40px 40px 40px; overflow-y: auto; }
.page-section { display: none; animation: fadeUp 0.3s ease forwards; }
.active-section { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 25px; }
.stat-card { background: var(--bg-card); padding: 20px; border-radius: var(--radius-lg); border: 1px solid var(--border-color); }
.stat-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.stat-header h3 { font-size: 0.9rem; color: var(--text-muted); font-weight: 600; }
.stat-icon { color: var(--text-muted); font-size: 1.2rem; opacity: 0.5; }
.stat-value { font-size: 2.2rem; font-weight: 800; text-align: left; direction: ltr; }
.text-gold { color: var(--gold-primary); font-size: 1.2rem; line-height: 2.5rem; }

.charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.chart-card { background: var(--bg-card); padding: 25px; border-radius: var(--radius-lg); border: 1px solid var(--border-color); }
.chart-card h3 { font-size: 1rem; color: var(--text-muted); margin-bottom: 20px; font-weight: 600; display: flex; gap: 10px; align-items: center; }

.form-container { max-width: 900px; margin: 0 auto; }
.form-card { background: var(--bg-card); padding: 30px; border-radius: var(--radius-lg); margin-bottom: 20px; border: 1px solid var(--border-color); }
.card-title { font-size: 1.1rem; margin-bottom: 25px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; color: var(--gold-primary); }
.input-row { display: flex; gap: 20px; }
.input-group { flex: 1; margin-bottom: 20px; text-align: center; }
.input-group label { display: block; margin-bottom: 12px; color: var(--text-muted); font-size: 0.9rem; font-weight: 700; }
.custom-input { width: 100%; padding: 15px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-md); color: var(--text-white); font-family: inherit; font-size: 0.95rem; text-align: center; transition: 0.3s; }
.custom-input:focus { outline: none; border-color: var(--gold-primary); }
.textarea-large { min-height: 120px; resize: none; text-align: right; }

.platforms-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; direction: ltr; }
.platform-checkbox { display: flex; justify-content: space-between; align-items: center; background: var(--bg-input); padding: 15px 20px; border-radius: var(--radius-md); cursor: pointer; border: 1px solid var(--border-color); font-weight: 700; color: var(--text-white); direction: rtl; }
.platform-checkbox input[type="checkbox"] { appearance: none; width: 20px; height: 20px; border: 2px solid var(--gold-primary); border-radius: 4px; background: transparent; cursor: pointer; position: relative; }
.platform-checkbox input[type="checkbox"]:checked { background: var(--gold-primary); }
.platform-checkbox input[type="checkbox"]:checked::after { content: '✔'; position: absolute; color: var(--bg-main); font-size: 12px; top: 1px; left: 3px; font-weight: bold; }

.form-actions { display: flex; justify-content: center; gap: 20px; margin-top: 30px; }
.btn-primary { background: var(--gold-primary); color: var(--bg-sidebar); border: none; padding: 15px 40px; border-radius: var(--radius-md); font-size: 1.1rem; font-weight: 800; cursor: pointer; font-family: inherit; display: flex; gap: 10px; align-items: center; }
.btn-primary:hover { background: var(--gold-hover); }

.results-layout { display: flex; gap: 30px; height: calc(100vh - 140px); }
.filters-sidebar { width: 250px; background: var(--bg-card); border-radius: var(--radius-lg); padding: 25px 20px; border: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 25px; }
.filter-header h3 { font-size: 1rem; color: var(--text-white); font-weight: 700; text-align: center; }
.filter-group h4 { font-size: 0.8rem; color: var(--gold-primary); margin-bottom: 15px; text-align: center; }
.filter-options { display: flex; flex-direction: column; gap: 10px; }
.filter-option { display: flex; justify-content: space-between; align-items: center; cursor: pointer; color: var(--text-muted); font-size: 0.9rem; direction: ltr; }
.filter-option span { direction: rtl; display: flex; align-items: center; gap: 8px; }
.filter-option input[type="radio"] { appearance: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text-muted); background: transparent; cursor: pointer; }
.filter-option input[type="radio"]:checked { border-color: var(--gold-primary); background: var(--gold-primary); }
.btn-reset-filters { background: transparent; border: none; color: var(--text-muted); font-family: inherit; font-size: 0.8rem; cursor: pointer; margin-top: auto; text-align: center; }

.results-main-area { flex-grow: 1; display: flex; justify-content: center; align-items: center; }
.empty-state { text-align: center; color: var(--text-muted); }
.text-muted-icon { font-size: 4rem; opacity: 0.2; margin-bottom: 20px; }
.btn-text-gold { background: transparent; border: none; color: var(--gold-primary); font-family: inherit; font-weight: 700; cursor: pointer; font-size: 1rem; margin-top: 15px;}

.llm-selector-grid { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px;}
.llm-pill { background: transparent; border: 1px solid var(--border-color); padding: 10px 20px; border-radius: 30px; color: var(--text-muted); cursor: pointer; font-family: inherit; font-weight: 700; display: flex; gap: 8px; align-items: center; transition: 0.3s; }
.llm-pill.active { background: var(--gold-primary); color: var(--bg-sidebar); border-color: var(--gold-primary); }
.input-with-icon { position: relative; width: 100%; }
.input-icon { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.pl-icon { padding-right: 40px; }
.input-hint { font-size: 0.75rem; color: var(--text-muted); text-align: center; margin-top: 10px; }
.btn-save { margin: 30px auto 0; width: fit-content; }

.danger-card { border: 1px solid var(--danger-bg); margin-top: 30px; }
.text-red { color: var(--danger-red); }
.danger-content { text-align: center; }
.danger-content p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px; }
.btn-danger { background: var(--danger-bg); color: var(--danger-red); border: 1px solid var(--danger-red); padding: 12px 30px; border-radius: var(--radius-md); font-family: inherit; font-weight: 700; cursor: pointer; }

.chat-widget-btn { position: fixed; bottom: 30px; left: 30px; width: 55px; height: 55px; background: var(--gold-primary); color: var(--bg-sidebar); border-radius: 14px; display: flex; justify-content: center; align-items: center; font-size: 1.5rem; cursor: pointer; z-index: 999; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.chat-popup { display: none; position: fixed; bottom: 95px; left: 30px; width: 360px; height: 480px; background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: 0 10px 30px rgba(0,0,0,0.5); flex-direction: column; z-index: 1000; border: 1px solid var(--border-color); overflow: hidden; }
.chat-header { background: var(--bg-main); padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); font-weight: 700; color: var(--gold-primary); }
.chat-header button { background: transparent; border: none; color: var(--text-white); cursor: pointer; font-size: 1.1rem; }
.chat-messages { flex-grow: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; }
.message { padding: 12px 16px; border-radius: var(--radius-md); font-size: 0.9rem; line-height: 1.5; max-width: 85%; }
.ai-msg { background: var(--bg-main); color: var(--text-white); border: 1px solid var(--border-color); align-self: flex-start; border-bottom-right-radius: 0; }
.user-msg { background: var(--gold-primary); color: var(--bg-sidebar); align-self: flex-end; border-bottom-left-radius: 0; font-weight: 700; }
.chat-input-area { display: flex; padding: 15px; background: var(--bg-main); border-top: 1px solid var(--border-color); gap: 10px; }
.chat-input-area input { flex-grow: 1; background: var(--bg-card); border: 1px solid var(--border-color); color: white; padding: 12px; border-radius: var(--radius-md); outline: none; font-family: inherit; }
.chat-input-area button { background: transparent; color: var(--gold-primary); border: none; cursor: pointer; font-size: 1.2rem; transform: rotate(180deg); padding: 0 10px; }

.coming-soon-state { height: calc(100vh - 200px); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 15px; }

#loading-overlay { position: fixed; inset: 0; background: rgba(7, 21, 38, 0.95); display: flex; justify-content: center; align-items: center; z-index: 9999; backdrop-filter: blur(8px); }
.loader-container { text-align: center; }
.golden-spinner { width: 90px; height: 90px; border: 5px solid rgba(212, 175, 55, 0.1); border-top: 5px solid var(--gold-primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 25px; }
.loading-percentage { font-size: 2.5rem; font-weight: 800; color: var(--gold-primary); margin-bottom: 10px; font-family: var(--font-main); }
.loading-text { color: var(--text-white); font-size: 1.1rem; font-weight: 600; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.results-grid { display: flex; flex-direction: column; gap: 15px; width: 100%; max-height: 75vh; overflow-y: auto; padding-right: 15px; }
.result-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 25px; width: 100%; transition: all 0.3s; }
.result-card:hover { border-color: var(--gold-primary); box-shadow: 0 5px 20px rgba(0,0,0,0.3); transform: translateY(-2px); }
.result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.result-platform { font-weight: 800; color: var(--gold-primary); display: flex; gap: 8px; align-items: center; font-size: 1.1rem; }
.result-sentiment { padding: 6px 15px; border-radius: 20px; font-size: 0.85rem; font-weight: bold; }
.sentiment-positive { background: rgba(46, 204, 113, 0.1); color: #2ecc71; border: 1px solid #2ecc71; }
.sentiment-negative { background: rgba(231, 76, 60, 0.1); color: #e74c3c; border: 1px solid #e74c3c; }
.sentiment-neutral { background: rgba(255, 255, 255, 0.1); color: #ccc; border: 1px solid #ccc; }
.result-content { font-size: 1rem; line-height: 1.7; color: var(--text-white); margin-bottom: 20px; }
.result-meta { background: var(--bg-main); padding: 15px; border-radius: var(--radius-sm); font-size: 0.85rem; color: var(--text-muted); display: flex; flex-direction: column; gap: 8px; border: 1px dashed var(--border-color); }
.result-link { display: inline-block; margin-top: 15px; color: var(--gold-primary); text-decoration: none; font-weight: 800; font-size: 0.95rem; }
.result-link:hover { text-decoration: underline; color: var(--gold-hover); }

.reports-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 20px; width: 100%; align-items: start;}
.report-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 25px; display: flex; flex-direction: column; gap: 15px; transition: 0.3s;}
.report-card:hover { border-color: var(--gold-primary); transform: translateY(-3px); box-shadow: 0 5px 20px rgba(0,0,0,0.3);}
.report-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px dashed var(--border-color); padding-bottom: 15px;}
.report-title { font-size: 1.2rem; font-weight: 800; color: var(--gold-primary); margin-bottom: 5px;}
.report-date { font-size: 0.85rem; color: var(--text-muted); }
.report-meta-item { font-size: 0.9rem; color: var(--text-white); line-height: 1.5;}
.report-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 5px; }
.r-tag { padding: 5px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: bold; background: var(--bg-main); border: 1px solid var(--border-color);}
.r-pos { color: #2ecc71; border-color: #2ecc71; background: rgba(46, 204, 113, 0.1);}
.r-neg { color: #e74c3c; border-color: #e74c3c; background: rgba(231, 76, 60, 0.1);}
.btn-open-report { background: var(--gold-primary); color: var(--bg-sidebar); border: none; padding: 12px; border-radius: var(--radius-md); font-weight: 800; cursor: pointer; text-align: center; margin-top: 10px; font-family: inherit; transition: 0.3s; width: 100%;}
.btn-open-report:hover { background: var(--gold-hover); }