@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&family=Tajawal:wght@300;400;500;700;800;900&display=swap');

:root {
    --bg-main: #0b0f19;
    --bg-surface: #121826;
    --bg-surface-card: #161f32;
    --bg-surface-hover: #1d2a44;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(255, 255, 255, 0.15);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent-emerald: #10b981;
    --accent-emerald-bg: rgba(16, 185, 129, 0.12);
    --accent-red: #ef4444;
    --accent-red-bg: rgba(239, 68, 68, 0.12);
    --accent-amber: #f59e0b;
    --accent-amber-bg: rgba(245, 158, 11, 0.12);
    --accent-blue: #3b82f6;
    --accent-blue-bg: rgba(59, 130, 246, 0.12);
    --accent-purple: #8b5cf6;
    --accent-purple-bg: rgba(139, 92, 246, 0.12);
    
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', 'Cairo', sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Gradients */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 45%),
        radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* App Layout */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1560px;
    margin: 0 auto;
    padding: 24px;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 24px;
}

/* Sidebar Navigation */
.sidebar {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px 16px;
    height: calc(100vh - 48px);
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    backdrop-filter: blur(12px);
}

.sidebar-header {
    margin-bottom: 32px;
    text-align: center;
}

.sidebar-logo {
    font-size: 20px;
    font-weight: 900;
    color: #fff;
    background: linear-gradient(135deg, #fff 0%, var(--accent-emerald) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.sidebar-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: var(--transition);
    border: 1px solid transparent;
}

.menu-item a:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
    border-color: var(--border-color);
}

.menu-item.active a {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(59, 130, 246, 0.1));
    color: #fff;
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* Main Content Area */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Header */
.main-header {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(12px);
}

.header-title-wrapper h1 {
    font-size: 24px;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, var(--accent-emerald) 60%, var(--accent-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-title-wrapper p {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge-live {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-emerald-bg);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.badge-live .pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-emerald);
    border-radius: 50%;
    animation: pulse 2s infinite;
    box-shadow: 0 0 8px var(--accent-emerald);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.system-truth-banner {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    font-size: 12.5px;
    color: #93c5fd;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Dashboard Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-highlight);
    box-shadow: var(--shadow);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
}

.stat-card.emerald::before { background: var(--accent-emerald); }
.stat-card.red::before { background: var(--accent-red); }
.stat-card.amber::before { background: var(--accent-amber); }
.stat-card.blue::before { background: var(--accent-blue); }
.stat-card.purple::before { background: var(--accent-purple); }

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.stat-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-secondary);
}

.stat-icon {
    font-size: 18px;
}

.stat-value {
    font-size: 26px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 6px;
}

.stat-desc {
    font-size: 11.5px;
    color: var(--text-muted);
}

/* Sections Layout */
.section-row-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.section-row-equal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Card Wrapper */
.panel-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    backdrop-filter: blur(12px);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-header h2 .icon {
    color: var(--accent-emerald);
}

/* AI Summary Panel */
.ai-summary-container {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(59, 130, 246, 0.06));
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-md);
    padding: 20px;
    position: relative;
}

.ai-summary-badge {
    position: absolute;
    top: -12px;
    right: 20px;
    background: linear-gradient(135deg, var(--accent-emerald), var(--accent-blue));
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.ai-summary-text {
    font-size: 13.5px;
    color: var(--text-primary);
    line-height: 1.7;
    margin-bottom: 12px;
}

.ai-summary-tips {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-tip-item {
    font-size: 12.5px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-tip-item::before {
    content: '✦';
    color: var(--accent-emerald);
    font-size: 10px;
}

/* Tables Styling */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: right;
}

.data-table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-weight: 700;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 11px;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.data-table tbody tr:hover {
    background: var(--bg-surface-hover);
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 10.5px;
    font-weight: 700;
    display: inline-block;
}

.badge.success { background: var(--accent-emerald-bg); color: var(--accent-emerald); }
.badge.danger { background: var(--accent-red-bg); color: var(--accent-red); }
.badge.warning { background: var(--accent-amber-bg); color: var(--accent-amber); }
.badge.info { background: var(--accent-blue-bg); color: var(--accent-blue); }

.risk-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.risk-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.risk-indicator.critical { color: var(--accent-red); }
.risk-indicator.critical .dot { background: var(--accent-red); box-shadow: 0 0 6px var(--accent-red); }
.risk-indicator.high { color: var(--accent-amber); }
.risk-indicator.high .dot { background: var(--accent-amber); }
.risk-indicator.low { color: var(--accent-emerald); }
.risk-indicator.low .dot { background: var(--accent-emerald); }

/* Integration Diagram styles */
.diagram-container {
    padding: 32px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
    gap: 24px;
    position: relative;
}

.diagram-node {
    background: var(--bg-surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    text-align: center;
    width: 180px;
    position: relative;
    z-index: 2;
    transition: var(--transition);
}

.diagram-node:hover {
    border-color: var(--accent-emerald);
    transform: translateY(-2px);
}

.diagram-node .icon {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.diagram-node h3 {
    font-size: 13.5px;
    font-weight: 800;
    margin-bottom: 4px;
}

.diagram-node p {
    font-size: 11px;
    color: var(--text-muted);
}

.diagram-arrow {
    font-size: 24px;
    color: var(--text-muted);
    font-weight: 900;
}

/* Chat Assistant Panel */
.chat-widget {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 380px;
    height: 480px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(20px);
}

.chat-widget-header {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(59, 130, 246, 0.15));
    border-bottom: 1px solid var(--border-color);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-widget-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-widget-title h3 {
    font-size: 14px;
    font-weight: 800;
}

.chat-widget-status {
    font-size: 11px;
    color: var(--accent-emerald);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 12.5px;
    line-height: 1.5;
}

.message.bot {
    background: var(--bg-surface-card);
    border: 1px solid var(--border-color);
    align-self: flex-start;
    border-top-right-radius: 4px;
}

.message.user {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(59, 130, 246, 0.1));
    border: 1px solid rgba(16, 185, 129, 0.3);
    align-self: flex-end;
    border-top-left-radius: 4px;
    color: #fff;
}

.chat-input-wrapper {
    border-top: 1px solid var(--border-color);
    padding: 12px;
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.chat-input-wrapper input {
    flex: 1;
    background: var(--bg-surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: #fff;
    font-family: inherit;
    font-size: 12.5px;
    outline: none;
    transition: var(--transition);
}

.chat-input-wrapper input:focus {
    border-color: var(--accent-emerald);
}

.chat-submit-btn {
    background: var(--accent-emerald);
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    cursor: pointer;
    font-size: 12.5px;
    transition: var(--transition);
}

.chat-submit-btn:hover {
    background: #059669;
}

/* Alert Backlog */
.backlog-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.backlog-item {
    background: var(--bg-surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.backlog-item:hover {
    border-color: var(--border-highlight);
}

.backlog-info h4 {
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 4px;
}

.backlog-info p {
    font-size: 11.5px;
    color: var(--text-muted);
}

.backlog-badge {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        height: auto;
        position: relative;
        top: 0;
    }
}

@media (max-width: 768px) {
    .section-row-2, .section-row-equal {
        grid-template-columns: 1fr;
    }
}
