:root {
    /* Futuristic Dark Theme Palette */
    --bg-color: #05050a;
    --bg-grid: rgba(0, 240, 255, 0.03);
    --sidebar-bg: #0a0a12;
    --sidebar-hover: #12121f;
    --card-bg: rgba(15, 15, 25, 0.7);
    --card-border: rgba(0, 240, 255, 0.15);
    --card-hover-border: rgba(0, 240, 255, 0.4);
    
    /* Typography */
    --text-main: #e0e0ff;
    --text-secondary: #8b9bb4;
    --text-muted: #5a6a85;
    --text-light: #ffffff;
    
    /* Accents & Glows */
    --primary-color: #00f0ff;
    --primary-glow: rgba(0, 240, 255, 0.3);
    --accent-color: #ff9d00;
    
    /* Sentiment Colors (Neon) */
    --color-positive: #00ffa3;
    --bg-positive: rgba(0, 255, 163, 0.1);
    --color-negative: #ff2a6d;
    --bg-negative: rgba(255, 42, 109, 0.1);
    --color-neutral: #8b9bb4;
    --bg-neutral: rgba(139, 155, 180, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', Roboto, monospace, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    line-height: 1.6;
    /* Subtle grid background for terminal feel */
    background-image: 
        linear-gradient(var(--bg-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 40px 40px;
    -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #2a2a40;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Authentication Screen */
#auth-screen {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 3rem 2.5rem;
    border-radius: 16px;
    box-shadow: 0 0 40px rgba(0, 240, 255, 0.1), inset 0 1px 0 rgba(255,255,255,0.05);
    width: 100%;
    max-width: 420px;
    text-align: center;
    margin: auto;
    border: 1px solid var(--card-border);
}

#auth-screen h2 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: -0.02em;
    text-shadow: 0 0 20px var(--primary-glow);
}

#auth-screen p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.hint-text {
    font-size: 0.8rem;
    color: var(--primary-color);
    background: rgba(0, 240, 255, 0.05);
    border: 1px solid rgba(0, 240, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 1.5rem;
    font-family: monospace;
}

.input-group { 
    margin: 1.5rem 0; 
}

input,
select {
    width: 100%;
    padding: 0.875rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: monospace;
    transition: all 0.3s ease;
    outline: none;
    color: var(--text-light);
}

select option {
    background: #0a0a1a;
    color: var(--text-light);
}

input:focus,
select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-glow);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #0088ff);
    color: #000;
    border: none;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-primary:hover {
    box-shadow: 0 0 25px var(--primary-glow);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Application Layout */
#app-layout {
    display: none;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Navigation */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    flex-shrink: 0;
    border-right: 1px solid var(--card-border);
    box-shadow: 5px 0 30px rgba(0,0,0,0.5);
}

.sidebar h2 {
    text-align: center;
    margin: 0 0 2rem 0;
    padding: 0 1.5rem;
    color: var(--text-light);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-shadow: 0 0 15px var(--primary-glow);
}

.nav-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-left: 3px solid transparent;
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    font-family: monospace;
}

.nav-btn:hover {
    background-color: var(--sidebar-hover);
    color: var(--text-light);
    border-left-color: var(--text-muted);
}

.nav-btn.active {
    background: linear-gradient(90deg, rgba(0, 240, 255, 0.1), transparent);
    color: var(--primary-color);
    font-weight: 600;
    border-left-color: var(--primary-color);
    text-shadow: 0 0 10px var(--primary-glow);
}

.user-profile-mini {
    margin-top: auto;
    padding: 1.25rem 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--card-border);
}

.profile-name {
    font-weight: 700; 
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
    font-family: monospace;
}

.profile-interests {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 2rem 2.5rem;
    overflow-y: auto;
    background: transparent;
}

.main-content h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: -0.02em;
}

.main-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

/* Page Sections */
.page {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.page.active {
    display: block;
}

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

/* UI Components - Glassmorphism Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

.card:hover {
    border-color: var(--card-hover-border);
    box-shadow: 0 8px 30px rgba(0, 240, 255, 0.1);
    transform: translateY(-2px);
}

.card-header {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-light);
    letter-spacing: 0.02em;
}

.news-item {
    border-left: 3px solid var(--card-border);
    padding-left: 1.25rem;
    margin-bottom: 1.5rem;
    background: var(--card-bg);
    padding: 1.25rem 1.25rem 1.25rem 1.5rem;
    border-radius: 0 8px 8px 0;
    transition: all 0.3s ease;
}

.news-item:hover {
    border-left-color: var(--primary-color);
    background: rgba(0, 240, 255, 0.03);
}

.news-item h3 {
    margin-top: 0.5rem; 
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
    line-height: 1.4;
    color: var(--text-light);
}

.news-item a {
    text-decoration: none; 
    color: var(--text-light);
    transition: color 0.2s;
}

.news-item a:hover {
    color: var(--primary-color);
    text-shadow: 0 0 8px var(--primary-glow);
}

.news-impact {
    font-size: 0.85rem; 
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 0.75rem;
    font-family: 'Inter', sans-serif;
}

.news-importance {
    font-weight: 600; 
    color: var(--accent-color);
    font-size: 0.75rem;
    margin-top: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: monospace;
}

.sentiment-positive { 
    background-color: var(--bg-positive); 
    color: var(--color-positive);
    border: 1px solid rgba(0, 255, 163, 0.3);
    box-shadow: 0 0 10px rgba(0, 255, 163, 0.1);
}
.sentiment-negative { 
    background-color: var(--bg-negative); 
    color: var(--color-negative);
    border: 1px solid rgba(255, 42, 109, 0.3);
    box-shadow: 0 0 10px rgba(255, 42, 109, 0.1);
}
.sentiment-neutral { 
    background-color: var(--bg-neutral); 
    color: var(--color-neutral);
    border: 1px solid rgba(139, 155, 180, 0.3);
}
.badge-live { 
    background-color: rgba(255, 157, 0, 0.15); 
    color: var(--accent-color);
    border: 1px solid rgba(255, 157, 0, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 5px var(--accent-color); }
    50% { opacity: 0.6; box-shadow: 0 0 15px var(--accent-color); }
}

/* Grid Layouts */
.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.text-positive { 
    color: var(--color-positive); 
    text-shadow: 0 0 8px rgba(0, 255, 163, 0.3);
}
.text-negative { 
    color: var(--color-negative); 
    text-shadow: 0 0 8px rgba(255, 42, 109, 0.3);
}

/* Empty State / Loading */
.hint-text-loading {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 2rem;
    background: transparent;
}

/* Live Chat Page Styles */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 60vh;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid var(--card-border);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
}

.chat-message {
    display: flex;
    margin-bottom: 1.25rem;
    animation: fadeIn 0.3s ease-out;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.bot {
    justify-content: flex-start;
}

.message-content {
    max-width: 75%;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.chat-message.user .message-content {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(0, 136, 255, 0.1));
    color: var(--text-light);
    border: 1px solid var(--card-hover-border);
    border-bottom-right-radius: 4px;
    backdrop-filter: blur(5px);
}

.chat-message.bot .message-content {
    background: rgba(15, 15, 25, 0.8);
    color: var(--text-main);
    border: 1px solid var(--card-border);
    border-bottom-left-radius: 4px;
    max-width: 92%;
}

/* Markdown formatting inside bot replies (strategist report) */
.chat-message.bot .message-content h3,
.chat-message.bot .message-content h4,
.chat-message.bot .message-content h5,
.chat-message.bot .message-content h6 {
    color: var(--primary-color);
    margin: 1rem 0 0.5rem;
    line-height: 1.3;
}
.chat-message.bot .message-content h3 { font-size: 1.1rem; }
.chat-message.bot .message-content h4 { font-size: 1rem; }
.chat-message.bot .message-content h5,
.chat-message.bot .message-content h6 { font-size: 0.92rem; }

.chat-message.bot .message-content p { margin: 0.5rem 0; }

.chat-message.bot .message-content ul,
.chat-message.bot .message-content ol {
    margin: 0.5rem 0;
    padding-inline-start: 1.5rem;
}
.chat-message.bot .message-content li { margin: 0.25rem 0; }

.chat-message.bot .message-content strong { color: var(--text-light); }

.chat-message.bot .message-content code {
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
    font-size: 0.85em;
}

.chat-message.bot .message-content hr {
    border: none;
    border-top: 1px solid var(--card-border);
    margin: 1rem 0;
}

.chat-message.bot .message-content .chat-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.82rem;
    display: block;
    overflow-x: auto;
}
.chat-message.bot .message-content .chat-table th,
.chat-message.bot .message-content .chat-table td {
    border: 1px solid var(--card-border);
    padding: 0.4rem 0.6rem;
    text-align: start;
}
.chat-message.bot .message-content .chat-table th {
    background: rgba(0, 240, 255, 0.08);
    color: var(--primary-color);
}

.chat-input-area {
    display: flex;
    gap: 0.75rem;
    background: transparent;
}

.chat-input-area input {
    flex: 1;
}

.send-btn {
    width: auto;
    padding: 0.875rem 1.5rem;
}

/* Language Toggle Buttons */
.lang-toggle {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--card-border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
}

.lang-btn.active {
    background: var(--primary-color);
    color: #000;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* RTL Support for Arabic */
html[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .sidebar {
    border-right: none;
    border-left: 1px solid var(--card-border);
    box-shadow: -5px 0 30px rgba(0,0,0,0.5);
}

html[dir="rtl"] .nav-btn {
    border-left: none;
    border-right: 3px solid transparent;
    text-align: right;
}

html[dir="rtl"] .nav-btn:hover,
html[dir="rtl"] .nav-btn.active {
    border-right-color: var(--primary-color);
    background: linear-gradient(-90deg, rgba(0, 240, 255, 0.1), transparent);
}

html[dir="rtl"] .news-item {
    border-left: none;
    border-right: 3px solid var(--card-border);
    padding-left: 1.25rem;
    padding-right: 1.5rem;
    border-radius: 8px 0 0 8px;
}

html[dir="rtl"] .news-item:hover {
    border-right-color: var(--primary-color);
}

html[dir="rtl"] .chat-message.user {
    justify-content: flex-start;
}

html[dir="rtl"] .chat-message.bot {
    justify-content: flex-end;
}

html[dir="rtl"] .chat-message.user .message-content {
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 4px;
}

html[dir="rtl"] .chat-message.bot .message-content {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
}

html[dir="rtl"] .card-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .card-header > div[style*="display:flex"] {
    flex-direction: row-reverse;
}

.typing-indicator {
    font-style: italic;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: monospace;
}

.typing-indicator::after {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
    box-shadow: 0 0 8px var(--primary-color);
}

@keyframes typing {
    0%, 100% { transform: scale(0); opacity: 0.5; }
    50% { transform: scale(1); opacity: 1; }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    #app-layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        padding: 1rem;
        border-right: none;
        border-bottom: 1px solid var(--card-border);
    }
    .sidebar h2 {
        display: none;
    }
    .nav-btn {
        width: auto;
        white-space: nowrap;
        padding: 0.75rem 1rem;
        border-left: none;
        border-bottom: 3px solid transparent;
    }
    .nav-btn.active {
        border-left: none;
        border-bottom-color: var(--primary-color);
        background: transparent;
    }
    .user-profile-mini {
        display: none;
    }
    .main-content {
        padding: 1.5rem;
    }
}