/* Reset & Global CSS Variables */
:root {
    --bg-main: #0B0F19; /* Deep Space Dark */
    --bg-sidebar: #111827; /* Dark Slate Gray */
    --bg-glass: rgba(17, 24, 39, 0.7);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(16, 185, 129, 0.12);
    
    --primary-color: #10B981; /* Legal Emerald Green */
    --primary-gradient: linear-gradient(135deg, #059669, #10B981);
    --primary-glow: rgba(16, 185, 129, 0.35);
    
    --secondary-color: #06B6D4; /* Trust Cyan */
    --secondary-gradient: linear-gradient(135deg, #0891B2, #06B6D4);
    --secondary-glow: rgba(6, 182, 212, 0.35);
    
    --accent-gold: #F59E0B; /* Authority Gold */
    --accent-blue: #3B82F6; /* Justice Blue */
    
    --text-main: #F3F4F6;
    --text-muted: #9CA3AF;
    --text-dark: #111827;
    
    --error-color: #EF4444;
    --success-color: #10B981;
    
    --transition-speed: 0.25s;
    --font-arabic: 'Cairo', sans-serif;
    --font-ui: 'Inter', 'Cairo', sans-serif;
}

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

body {
    font-family: var(--font-arabic);
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* App Container Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
    background: radial-gradient(circle at 80% 20%, rgba(6, 182, 212, 0.04) 0%, transparent 45%),
                radial-gradient(circle at 10% 85%, rgba(16, 185, 129, 0.04) 0%, transparent 45%);
}

/* Sidebar Backdrop Overlay for mobile drawer */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 7, 18, 0.6);
    backdrop-filter: blur(4px);
    z-index: 997;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Close Button inside Sidebar (hidden on desktop) */
.sidebar-close-btn {
    display: none;
}

/* Sidebar Navigation Styling */
.sidebar {
    width: 300px;
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-shrink: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.logo-area h2 {
    font-size: 20px;
    font-weight: 800;
}

.badge {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 12px;
    font-weight: 700;
}

/* Navigation Menu Items */
.sidebar-menu {
    list-style-type: none;
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    border-right: 3px solid transparent;
}

.menu-item i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    transition: color var(--transition-speed) ease;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-main);
}

.menu-item.active {
    background: rgba(16, 185, 129, 0.08);
    color: var(--primary-color);
    border-right-color: var(--primary-color);
    box-shadow: -5px 0 15px rgba(16, 185, 129, 0.03);
}

.sidebar-section-mini {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.active-folder-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
}

.active-folder-badge i {
    color: var(--secondary-color);
    flex-shrink: 0;
}

.active-folder-badge span {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    direction: ltr;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.1);
}

/* Workspace Panels Routing */
.workspace-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.tab-content {
    display: none;
    height: 100%;
    width: 100%;
    flex-direction: column;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

.workspace-header {
    height: 70px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-sidebar);
    flex-shrink: 0;
}

.workspace-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.header-status-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
}

.workspace-body {
    flex-grow: 1;
    padding: 30px;
}

.workspace-body.scrollable {
    overflow-y: auto;
}

.workspace-body.scrollable::-webkit-scrollbar {
    width: 6px;
}

.workspace-body.scrollable::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* Statistics Grid (Dashboard) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    transition: transform var(--transition-speed) ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon-wrapper {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon-wrapper.blue { background: rgba(59, 130, 246, 0.1); color: var(--accent-blue); }
.stat-icon-wrapper.green { background: rgba(16, 185, 129, 0.1); color: var(--primary-color); }
.stat-icon-wrapper.gold { background: rgba(245, 158, 11, 0.1); color: var(--accent-gold); }
.stat-icon-wrapper.cyan { background: rgba(6, 182, 212, 0.1); color: var(--secondary-color); }

.stat-details h3 {
    font-size: 24px;
    font-weight: 800;
    line-height: 1.2;
}

.stat-details p {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

/* Dashboard Card Grids */
.dashboard-columns {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.flex-grow-1 { flex: 1 1 300px; }
.flex-grow-2 { flex: 2 1 500px; }

.dash-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    overflow: hidden;
    backdrop-filter: blur(12px);
}

.dash-card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.01);
}

.dash-card-header h3 {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dash-card-body {
    padding: 24px;
}

.card-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.6;
}

.quick-ask-box {
    display: flex;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    border-radius: 10px;
}

.quick-ask-box input {
    flex-grow: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-family: var(--font-arabic);
    font-size: 13px;
}

.guide-box {
    background: rgba(6, 182, 212, 0.03);
    border: 1px solid rgba(6, 182, 212, 0.1);
    border-radius: 10px;
    padding: 16px;
}

.guide-box p {
    font-size: 12px;
    line-height: 1.8;
    color: var(--text-muted);
}

.quick-links-list {
    list-style-type: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quick-links-list li {
    font-size: 13px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    line-height: 1.5;
}

.quick-links-list strong {
    color: var(--primary-color);
}

/* Chat Layout Custom Wrapper */
.chat-layout-wrapper {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
    position: relative;
    height: calc(100% - 70px);
}

.chat-area-custom {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-footer-custom {
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
}

.suggestions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.suggestion-chip {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 12px;
    font-family: var(--font-arabic);
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.suggestion-chip:hover {
    background: rgba(16, 185, 129, 0.06);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.sources-sidebar-custom {
    width: 380px;
    height: 100%;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    position: absolute;
    left: 0;
    top: 0;
    z-index: 50;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.sources-sidebar-custom.active {
    transform: translateX(0);
}

/* Citations Sidebar Content Styles */
.sources-header {
    height: 70px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.15);
}

.sources-header h3 {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

.sources-content {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.no-sources-selected {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.6;
    margin: auto 0;
}

.source-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color var(--transition-speed) ease;
}

.source-card:hover {
    border-color: rgba(6, 182, 212, 0.25);
}

.source-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}

.source-badge-index {
    color: var(--secondary-color);
    font-weight: 700;
}

.source-meta-info {
    color: var(--text-muted);
    font-weight: 600;
}

.source-text-block {
    background: rgba(0, 0, 0, 0.15);
    border-right: 3px solid var(--secondary-color);
    border-radius: 4px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-muted);
    max-height: 250px;
    overflow-y: auto;
}

/* Search Panels (Legislation & Court Rulings) */
.search-bar-panel {
    display: flex;
    gap: 14px;
    margin-bottom: 24px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: 12px;
}

.search-input-wrapper {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 12px;
}

.search-bar-icon {
    color: var(--text-muted);
}

.search-input-wrapper input {
    flex-grow: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-family: var(--font-arabic);
    font-size: 14px;
    padding: 10px 0;
}

/* Legislation Cards UI */
.law-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.law-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 12px;
    margin-bottom: 14px;
}

.law-card-header h3 {
    font-size: 16px;
    color: var(--primary-color);
    font-weight: 700;
}

.articles-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.article-item {
    background: rgba(0, 0, 0, 0.15);
    border-right: 3px solid var(--primary-color);
    border-radius: 4px;
    padding: 12px 16px;
}

.article-item strong {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--primary-color);
}

.article-item p {
    font-size: 13px;
    line-height: 1.6;
}

/* Rulings Card UI */
.ruling-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border-right: 4px solid var(--accent-gold);
}

.ruling-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 8px;
}

.ruling-case-num {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-gold);
}

.ruling-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.ruling-principle {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.6;
    margin-bottom: 12px;
    color: var(--text-main);
}

.ruling-details {
    background: rgba(0, 0, 0, 0.15);
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-muted);
}

/* Templates & Contracts Layout */
.templates-layout-wrapper {
    display: flex;
    flex-grow: 1;
    height: calc(100% - 70px);
    overflow: hidden;
}

.templates-selector-panel {
    width: 280px;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.templates-selector-panel h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.template-categories-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.template-category-group h4 {
    font-size: 12px;
    color: var(--primary-color);
    margin-bottom: 8px;
    font-weight: 700;
}

.template-category-group ul {
    list-style-type: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.template-item {
    font-size: 12px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-speed) ease;
}

.template-item:hover {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-main);
}

.template-item.active {
    background: rgba(6, 182, 212, 0.1);
    color: var(--secondary-color);
    font-weight: 600;
}

/* Templates Editor Panel */
.templates-editor-panel {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
}

.editor-header {
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.editor-header h3 {
    font-size: 14px;
    font-weight: 700;
}

.editor-body {
    flex-grow: 1;
    padding: 20px;
}

.editor-body textarea {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    color: #E5E7EB;
    font-family: 'Cairo', monospace;
    font-size: 14px;
    line-height: 1.8;
    outline: none;
    resize: none;
    transition: border-color var(--transition-speed) ease;
}

.editor-body textarea:focus {
    border-color: var(--secondary-color);
}

/* Sync Dashboard Card */
.sync-dashboard-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    backdrop-filter: blur(12px);
    margin-bottom: 30px;
}

.sync-card-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.folder-big-icon {
    font-size: 40px;
    color: var(--secondary-color);
}

.folder-details-block h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.folder-details-block p {
    font-size: 13px;
    font-family: monospace;
    color: var(--text-muted);
    direction: ltr;
    text-align: right;
}

.folder-details-block small {
    font-size: 11px;
    color: var(--text-muted);
}

/* Messages container & bubbles styling */
.messages-container {
    flex-grow: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.message {
    display: flex;
    gap: 16px;
    max-width: 80%;
    animation: messageSlideIn 0.3s ease;
}

.message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.bot-message {
    align-self: flex-start;
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: var(--secondary-gradient);
}

.bot-message .message-avatar {
    background: var(--primary-gradient);
    box-shadow: 0 0 8px var(--primary-glow);
}

.message-bubble {
    border-radius: 16px;
    padding: 14px 18px;
    line-height: 1.6;
    font-size: 14px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
    color: var(--text-main);
}

.bot-message .message-bubble {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-top-right-radius: 4px;
    color: var(--text-main);
}

.message-sources {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.message-sources span {
    font-size: 11px;
    color: var(--text-muted);
}

.citation-badge {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid var(--secondary-color);
    color: var(--secondary-color);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all var(--transition-speed) ease;
}

.citation-badge:hover {
    background: var(--secondary-color);
    color: var(--text-dark);
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.3);
}

/* Chat Input Bar Form */
.chat-form {
    display: flex;
    gap: 12px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    transition: border-color var(--transition-speed) ease;
}

.chat-form:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.1);
}

.chat-form input {
    flex-grow: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-family: var(--font-arabic);
    font-size: 14px;
    padding: 8px;
}

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

/* Modals & Popups */
.modal-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-speed) ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-card {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 48px rgba(0,0,0,0.5);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform var(--transition-speed) cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    flex: 1;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: rgba(0,0,0,0.1);
}

/* Form Controls & Labels */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-main);
    font-family: var(--font-arabic);
    font-size: 14px;
    outline: none;
    transition: all var(--transition-speed) ease;
}

.form-control:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.05);
}

.input-with-action {
    display: flex;
    gap: 8px;
}

.input-with-action input {
    flex-grow: 1;
}

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

/* General Buttons */
.btn {
    font-family: var(--font-arabic);
    border: none;
    outline: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-speed) ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-gradient);
    color: var(--text-dark);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 0 15px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 15px;
}

/* Document List Cards (Manager) */
.docs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.doc-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.doc-info {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.doc-file-icon {
    font-size: 20px;
    color: #EF4444;
}

.doc-details {
    overflow: hidden;
}

.doc-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.doc-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-danger-icon {
    color: var(--text-muted);
    background: transparent;
    padding: 6px;
}

.btn-danger-icon:hover {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
}

/* Toast Alerts */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #111827;
    border-right: 4px solid var(--primary-color);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    z-index: 2000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.error {
    border-right-color: var(--error-color);
}

/* Welcome screen updates */
.welcome-box {
    max-width: 700px;
    margin: 30px auto;
    padding: 35px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.4), rgba(15, 23, 42, 0.4));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.4);
    backdrop-filter: blur(16px);
    animation: messageSlideIn 0.5s ease-out;
}

.welcome-icon-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.1));
    border: 1px solid rgba(16, 185, 129, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px auto;
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.15);
}

.welcome-icon {
    font-size: 36px;
    background: linear-gradient(135deg, #10b981, #0ea5e9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.4));
}

.welcome-box h1 {
    font-size: 26px;
    margin-bottom: 12px;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-desc {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 30px;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
}

/* Suggestion Grid ChatGPT/Gemini Style */
.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 20px;
}

@media (max-width: 600px) {
    .suggestions-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

.suggestion-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: right;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.suggestion-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.suggestion-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--primary-color);
    transition: all 0.3s ease;
}

.suggestion-card:hover .suggestion-card-icon {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
    color: var(--primary-color);
}

.suggestion-card-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.5;
    flex: 1;
    transition: all 0.3s ease;
}

.suggestion-card:hover .suggestion-card-text {
    color: var(--text-main);
}

/* Chat Input Area Upgrade */
.chat-footer-custom {
    padding: 16px 20px;
    background: transparent;
    border: none;
}

.chat-form-wrapper {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.chat-input-container {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    backdrop-filter: blur(12px);
    transition: all 0.3s ease;
}

.chat-input-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.15);
    background: rgba(30, 41, 59, 0.8);
}

.chat-input-container textarea {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-family: var(--font-arabic);
    font-size: 14px;
    line-height: 1.5;
    padding: 6px 4px;
    resize: none;
    max-height: 150px;
    min-height: 24px;
    overflow-y: auto;
}

.chat-input-container textarea::placeholder {
    color: var(--text-muted);
}

.chat-input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 8px;
}

.chat-input-actions .action-btn {
    background: transparent;
    border: none;
    outline: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 15px;
    transition: all 0.2s ease;
}

.chat-input-actions .action-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.chat-input-actions .send-btn {
    background: var(--primary-gradient);
    border: none;
    outline: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dark);
    cursor: pointer;
    font-size: 15px;
    box-shadow: 0 4px 10px var(--primary-glow);
    transition: all 0.2s ease;
}

.chat-input-actions .send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 15px var(--primary-glow);
}

/* Rich Markdown Content Styling for Bot Responses */
.message-bubble ul, .message-bubble ol {
    margin: 8px 0;
    padding-right: 24px;
}

.message-bubble li {
    margin-bottom: 6px;
    line-height: 1.6;
}

.message-bubble blockquote {
    border-right: 4px solid var(--primary-color);
    background: rgba(255, 255, 255, 0.02);
    padding: 10px 16px;
    margin: 12px 0;
    border-radius: 0 6px 6px 0;
    font-style: italic;
    color: var(--text-muted);
}

/* Code Block Styling */
.code-block-container {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin: 12px 0;
    overflow: hidden;
    direction: ltr;
    text-align: left;
}

.code-block-header {
    background: #1e293b;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-family: monospace;
    font-size: 12px;
    color: #94a3b8;
}

.code-block-header .copy-code-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-arabic);
    transition: all 0.2s ease;
}

.code-block-header .copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.code-block-container pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
}

.code-block-container code {
    font-family: 'Consolas', 'Courier New', Courier, monospace;
    font-size: 13.5px;
    color: #e2e8f0;
    line-height: 1.5;
}

/* Inline code highlight */
code:not(pre code) {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 13px;
    color: var(--secondary-color);
    direction: ltr;
    display: inline-block;
}

.tips-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 16px;
    text-align: right;
}

.tips-box strong {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--primary-color);
}

.tips-box ul {
    list-style-type: none;
}

.tips-box li {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    position: relative;
    padding-right: 14px;
}

.tips-box li::before {
    content: "•";
    color: var(--primary-color);
    position: absolute;
    right: 0;
}

/* Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}

.sync-icon.spinning {
    animation: spin 1.5s infinite linear;
}

.loading-spinner {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}

.loading-spinner::before {
    content: "🔄";
    display: block;
    font-size: 30px;
    margin-bottom: 12px;
    animation: spin 1.5s infinite linear;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 6px 12px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

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

/* Responsive grid layouts */
@media (max-width: 1100px) {
    .templates-layout-wrapper {
        flex-direction: column;
    }
    .templates-selector-panel {
        width: 100%;
        height: 200px;
        border-left: none;
        border-bottom: 1px solid var(--border-color);
    }
    .templates-editor-panel {
        height: calc(100% - 200px);
    }
}



/* Progress Bar & Terminal Sync Console CSS */
.sync-progress-details-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
    background: rgba(17, 24, 39, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    backdrop-filter: blur(8px);
}

.sync-live-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.sync-stat-item {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.sync-stat-title {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

.sync-stat-val {
    font-size: 13px;
    font-weight: 700;
    color: var(--secondary-color);
    word-break: break-all;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-bar-wrapper {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--secondary-gradient);
    box-shadow: 0 0 8px var(--secondary-glow);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.terminal-console-wrapper {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: #030712;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

.terminal-header {
    background: #111827;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    border-bottom: 1px solid var(--border-color);
}

.terminal-title {
    color: var(--text-muted);
    font-weight: 600;
}

.terminal-indicator {
    color: var(--primary-color);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.terminal-console {
    height: 220px;
    overflow-y: auto;
    padding: 14px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 12px;
    color: #34D399;
    line-height: 1.6;
    text-align: left;
    direction: ltr;
}

.terminal-console::-webkit-scrollbar {
    width: 6px;
}
.terminal-console::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* ============================================================
   NEW FEATURES — CONTRACT BUILDER, ANALYZER, CASES, CALCULATOR
   ============================================================ */

/* ── CSS Variables for new accent colors ── */
:root {
    --accent-purple: #8B5CF6;
    --accent-purple-glow: rgba(139, 92, 246, 0.3);
}

/* ── Contract Builder Layout ── */
.contract-builder-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 20px;
    height: calc(100vh - 90px);
    padding: 20px;
    overflow: hidden;
}

.contract-form-panel {
    overflow-y: auto;
    height: 100%;
}

.contract-form-panel::-webkit-scrollbar { width: 5px; }
.contract-form-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.contract-output-panel {
    height: 100%;
    overflow: hidden;
}

.contract-output-area {
    height: 100%;
    overflow-y: auto;
    padding: 24px;
    direction: rtl;
}

.contract-output-area::-webkit-scrollbar { width: 5px; }
.contract-output-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.empty-placeholder-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

.empty-placeholder-box p {
    font-size: 0.95rem;
    line-height: 1.7;
    max-width: 380px;
}

/* Contract text rendering */
.contract-text {
    font-size: 0.93rem;
    line-height: 1.9;
    color: var(--text-main);
    white-space: pre-wrap;
}

.contract-text h3 {
    font-size: 1rem;
    margin: 20px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.contract-list-item {
    display: flex;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.contract-item-num {
    font-weight: 700;
    color: var(--accent-blue);
    min-width: 24px;
}

/* AI Loading animation */
.ai-loading-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 20px;
    color: var(--text-muted);
}

.ai-loader-dots {
    display: flex;
    gap: 8px;
}

.ai-loader-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    animation: dot-bounce 1.2s ease-in-out infinite;
}

.ai-loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-loader-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-bounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
    40% { transform: scale(1.2); opacity: 1; }
}

/* Error box */
.error-box {
    padding: 20px 24px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    color: #f87171;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin: 24px;
}

/* ── Document Analyzer Layout ── */
.analyzer-layout {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 20px;
    height: calc(100vh - 90px);
    padding: 20px;
    overflow: hidden;
}

.analyzer-input-panel {
    overflow-y: auto;
    height: 100%;
}

.analyzer-output-panel {
    height: 100%;
    overflow: hidden;
}

/* Upload Drop Zone */
.upload-drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    background: rgba(255,255,255,0.02);
    margin-bottom: 4px;
}

.upload-drop-zone:hover,
.upload-drop-zone.drag-active {
    border-color: var(--primary-color);
    background: rgba(16, 185, 129, 0.06);
}

.upload-drop-zone p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 4px;
}

/* OR divider */
.or-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 16px 0;
}

.or-divider::before,
.or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* ── Case Manager ── */
.cases-stats-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 4px 0;
}

.case-stat-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.case-stat-chip.blue {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.25);
    color: #93c5fd;
}

.case-stat-chip.green {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.25);
    color: #6ee7b7;
}

.case-stat-chip.gold {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.25);
    color: #fcd34d;
}

.case-stat-chip.red {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

/* Cases Table */
.cases-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.cases-table th,
.cases-table td {
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.cases-table thead th {
    background: rgba(255,255,255,0.03);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.cases-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

.empty-table-msg {
    text-align: center !important;
    color: var(--text-muted);
    padding: 40px !important;
    font-style: italic;
}

/* Case Status badges */
.case-status {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 600;
}

.case-status.status-active {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16,185,129,0.3);
}

.case-status.status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245,158,11,0.3);
}

.case-status.status-closed {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239,68,68,0.25);
}

.case-type-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    background: rgba(139, 92, 246, 0.12);
    color: #c4b5fd;
    border: 1px solid rgba(139,92,246,0.2);
}

.btn-danger-icon {
    color: #f87171 !important;
}
.btn-danger-icon:hover {
    background: rgba(239, 68, 68, 0.1) !important;
}

/* ── Deadline Calculator ── */
.calculator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
    padding: 20px;
}

.calc-card {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    transition: box-shadow 0.25s;
}

.calc-card:hover {
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.calc-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    font-size: 1rem;
    font-weight: 700;
}

.calc-card-header.blue {
    background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(59,130,246,0.05));
    border-bottom: 1px solid rgba(59,130,246,0.2);
    color: #93c5fd;
}

.calc-card-header.gold {
    background: linear-gradient(135deg, rgba(245,158,11,0.15), rgba(245,158,11,0.05));
    border-bottom: 1px solid rgba(245,158,11,0.2);
    color: #fcd34d;
}

.calc-card-header.green {
    background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(16,185,129,0.05));
    border-bottom: 1px solid rgba(16,185,129,0.2);
    color: #6ee7b7;
}

.calc-card-header.purple {
    background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(139,92,246,0.05));
    border-bottom: 1px solid rgba(139,92,246,0.2);
    color: #c4b5fd;
}

.calc-card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.calc-result {
    margin-top: 8px;
    min-height: 40px;
}

.calc-result-box {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.7;
    animation: fadeInUp 0.3s ease;
}

.calc-result-box.valid {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16,185,129,0.2);
}

.calc-result-box.expired {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239,68,68,0.2);
}

.calc-result-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}

.calc-error {
    color: #f87171;
    font-size: 0.85rem;
}

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

/* form-group spacing refinement for new sections */
#tab-contract-builder .form-group,
#tab-analyzer .form-group,
#tab-cases .form-group {
    margin-bottom: 14px;
}

#tab-contract-builder .form-group label,
#tab-analyzer .form-group label,
#tab-cases .form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 1100px) {
    .contract-builder-layout { grid-template-columns: 1fr; overflow-y: auto; height: auto; }
    .analyzer-layout { grid-template-columns: 1fr; overflow-y: auto; height: auto; }
}

/* ────────────────────────────────────────────────────────────────────────
   New styling for level 4 / final phase features
   ──────────────────────────────────────────────────────────────────────── */

/* Split Pane Layout (for side-by-side translation and comparison) */
.split-pane {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.pane {
    display: flex;
    flex-direction: column;
}
.font-bold {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Diff visual comparison output viewer */
.diff-viewer-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 18px;
    border-radius: 8px;
    font-family: 'Courier New', Courier, monospace;
    white-space: pre-wrap;
    line-height: 1.8;
    direction: rtl;
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.95rem;
}
.diff-equal {
    color: var(--text-main);
}
.diff-delete {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    text-decoration: line-through;
    padding: 2px 4px;
    border-radius: 3px;
    margin: 0 1px;
}
.diff-insert {
    background-color: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
    margin: 0 1px;
}

/* Custom update-card hover effect */
.update-card {
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.22s ease;
}
.update-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

@media (max-width: 768px) {
    .split-pane {
        grid-template-columns: 1fr;
    }
}

/* Glassmorphism Login screen styling */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 50%, rgba(11, 15, 25, 0.95) 0%, rgba(6, 9, 15, 0.99) 100%);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.login-card {
    background: rgba(17, 24, 39, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 40px rgba(16, 185, 129, 0.05);
    text-align: center;
    animation: loginFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loginFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-logo {
    font-size: 54px;
    background: linear-gradient(135deg, #10B981, #06B6D4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(16, 185, 129, 0.25));
    margin-bottom: 24px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 10px;
    color: var(--text-main);
}

.login-header p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 30px;
    line-height: 1.5;
}

.or-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin: 20px 0;
}

.or-divider::before, .or-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.or-divider:not(:empty)::before {
    margin-left: 15px;
}

.or-divider:not(:empty)::after {
    margin-right: 15px;
}

.dev-login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-footer {
    margin-top: 40px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.2);
}

/* Pulsing audio mic animation when listening */
.mic-pulsing {
    background-color: #ef4444 !important;
    color: white !important;
    animation: micPulse 1.2s infinite ease-in-out;
}

@keyframes micPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Sidebar Chat sessions styling */
.sidebar-chat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    border-right: 3px solid transparent;
}

.sidebar-chat-item:hover {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-main);
}

.sidebar-chat-item.active {
    background: rgba(16, 185, 129, 0.05);
    color: var(--primary-color);
    border-right-color: var(--primary-color);
}

.sidebar-chat-item .chat-delete-btn {
    opacity: 0;
    transition: opacity 0.2s ease;
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 0.85rem;
}

.sidebar-chat-item:hover .chat-delete-btn {
    opacity: 1;
}

.sidebar-chat-item .chat-title-span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    margin-left: 8px;
    text-align: right;
}

.login-tabs button {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    color: var(--text-muted) !important;
    cursor: pointer;
    transition: all 0.2s ease;
}

.login-tabs button:hover {
    background: rgba(255, 255, 255, 0.07) !important;
    color: var(--text-main) !important;
}

.login-tabs button.active {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #000000 !important;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}
.speak-msg-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-arabic);
    cursor: pointer;
    transition: all 0.2s ease;
}

.speak-msg-btn:hover {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--text-main);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

@media (max-width: 768px) {
    /* Show Hamburger menu toggle button */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: rgba(17, 24, 39, 0.85);
        backdrop-filter: blur(10px);
        border: 1px solid var(--border-color);
        color: var(--text-main);
        font-size: 18px;
        z-index: 999;
        cursor: pointer;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), 0 0 10px rgba(16, 185, 129, 0.1);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .mobile-menu-toggle:hover {
        background: rgba(17, 24, 39, 0.95);
        border-color: var(--primary-color);
    }

    /* Fade out the hamburger menu when drawer is open */
    body.sidebar-open .mobile-menu-toggle {
        opacity: 0 !important;
        pointer-events: none !important;
        transform: scale(0.7) !important;
    }

    /* Sidebar drawer on mobile */
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        right: 0;
        width: 270px;
        height: 100vh;
        z-index: 998;
        transform: translateX(100%); /* Slide out to the right */
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -8px 0 25px rgba(0, 0, 0, 0.5);
        overflow: hidden;
    }
    
    .sidebar.open {
        transform: translateX(0); /* Slide in from the right */
    }

    /* Style Close Button inside Sidebar */
    .sidebar-close-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid var(--border-color);
        width: 30px;
        height: 30px;
        border-radius: 50%;
        color: var(--text-main);
        cursor: pointer;
        font-size: 14px;
        transition: all var(--transition-speed) ease;
    }
    .sidebar-close-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        color: var(--error-color);
        border-color: rgba(239, 68, 68, 0.3);
    }

    .sidebar-header {
        padding: 14px 16px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }

    .logo-area {
        gap: 8px !important;
    }
    .logo-area h2 {
        font-size: 16px !important;
    }
    .logo-icon {
        font-size: 20px !important;
    }
    .logo-area .badge {
        font-size: 8px !important;
        padding: 1px 4px !important;
    }

    /* Sidebar navigation menu lists */
    .sidebar-menu {
        padding: 8px 4px !important;
        gap: 4px !important;
    }
    .menu-item {
        padding: 8px 12px !important;
        font-size: 12.5px !important;
        gap: 10px !important;
        border-radius: 6px !important;
    }
    .menu-item i {
        font-size: 15px !important;
        width: 16px !important;
    }

    /* User Profile section on mobile */
    .sidebar-footer {
        padding: 10px 12px !important;
    }
    .user-profile-section {
        padding-top: 8px !important;
    }
    #user-avatar {
        width: 28px !important;
        height: 28px !important;
        margin-left: 6px !important;
    }
    #user-name {
        font-size: 0.78rem !important;
    }
    #user-email {
        font-size: 0.65rem !important;
    }
    #settings-trigger {
        padding: 8px 12px !important;
        font-size: 12.5px !important;
    }

    /* Layout grid reset on mobile */
    .app-container {
        flex-direction: column;
    }
    
    .workspace-container {
        width: 100%;
        height: 100vh;
        padding-top: 0;
    }

    /* Make workspace headers responsive, compact and horizontally aligned */
    .workspace-header {
        padding: 10px 60px 10px 12px !important; /* Leave space on the right for menu toggle button */
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        height: auto !important;
        min-height: 56px !important;
        background: rgba(17, 24, 39, 0.4);
        backdrop-filter: blur(8px);
    }
    
    .workspace-header h2 {
        font-size: 0.95rem !important; /* Prevent text taking up too much space */
        font-weight: 700;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
        overflow: hidden !important;
        max-width: 48% !important;
        line-height: 1.2;
    }
    
    .header-status-info {
        font-size: 0.7rem !important;
        gap: 6px !important;
        max-width: 48% !important;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    
    .provider-label-top {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        max-width: 80px;
    }

    /* Compact 2-column Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        padding: 8px !important;
        margin-bottom: 16px !important;
    }
    
    .stat-card {
        padding: 10px 8px !important;
        gap: 8px !important;
        border-radius: 12px !important;
    }
    
    .stat-icon-wrapper {
        width: 36px !important;
        height: 36px !important;
        font-size: 16px !important;
        border-radius: 8px !important;
    }
    
    .stat-details h3 {
        font-size: 16px !important;
    }
    
    .stat-details p {
        font-size: 9px !important;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
    }
    
    .workspace-body {
        padding: 10px !important;
    }

    /* Chat Messages adjustments */
    .message {
        max-width: 92% !important;
        padding: 10px 12px !important;
        font-size: 0.88rem !important;
    }
    
    .chat-layout-wrapper {
        height: auto !important;
    }
    
    .chat-footer-custom {
        padding: 10px 15px !important;
    }
    
    .chat-input-area {
        padding: 10px !important;
    }
    
    .input-wrapper {
        padding: 6px 10px !important;
    }
    
    #chat-input {
        font-size: 0.88rem !important;
        max-height: 80px !important;
    }

    /* Settings modal improvements */
    .modal-card {
        width: 95% !important;
        max-height: 95vh !important;
    }
    
    .settings-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Workspace header buttons responsive adjustments */
    .workspace-header .btn-text {
        display: none !important;
    }
    .workspace-header button {
        padding: 0 !important;
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        border-radius: 50% !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0 !important;
    }
    .workspace-header button i {
        margin: 0 !important;
        font-size: 14px !important;
    }

    /* Document cards and sync panels */
    .sync-dashboard-card {
        padding: 12px !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    
    .sync-live-stats {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    /* Citations sidebar custom width */
    .sources-sidebar-custom {
        width: 100% !important;
        border-right: none !important;
    }
}

/* ==========================================================================
   New Premium Legal Citations & Modals Styles (Iqrar AI Style)
   ========================================================================== */

/* --- Legal References Box and Items --- */
.legal-references-box {
    margin-top: 12px;
    padding: 12px 14px;
    background: rgba(16, 185, 129, 0.03);
    border: 1px solid rgba(16, 185, 129, 0.08);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: right;
}

.legal-references-box .references-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary-color);
}

.legal-references-box .references-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reference-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.reference-item:hover {
    background: rgba(16, 185, 129, 0.06);
    border-color: rgba(16, 185, 129, 0.15);
}

.reference-icon {
    color: var(--primary-color);
    font-size: 0.95rem;
}

.reference-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.reference-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    max-width: 80%;
}

.reference-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
}

.status-sari {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-ruling {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.status-book {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.sources-details-btn {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    font-size: 0.78rem;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition-speed);
}

.sources-details-btn:hover {
    background: rgba(16, 185, 129, 0.1);
    color: var(--text-main);
    border-color: var(--primary-color);
}

/* --- Sources Sidebar List (Drawer) --- */
.sidebar-source-card {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    text-align: right;
}

.sidebar-source-card:hover {
    background: rgba(16, 185, 129, 0.04);
    border-color: rgba(16, 185, 129, 0.15);
}

.sidebar-source-card-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.5;
    padding-left: 24px;
}

.sidebar-source-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.source-card-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.badge-sari {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-law {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-ruling {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.sidebar-source-card-arrow {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* --- Preview Modal --- */
.source-preview-card {
    background: rgba(15, 23, 42, 0.85) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    text-align: right;
}

.preview-badge {
    font-size: 0.68rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
}

/* --- Warning/Amber Button --- */
.btn-warning {
    background: #eab308;
    color: #0f172a;
    border: 1px solid #ca8a04;
    transition: all var(--transition-speed);
}

.btn-warning:hover {
    background: #ca8a04;
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.3);
}


