:root {
    --primary: #c1a87d;
    --primary-light: #d4c4a8;
    --primary-dark: #8e744a;
    --accent: #d4c4a8;
    --bg-dark: #0f1115;
    --bg-card: #1a1e26;
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #e8e8e8;
    --text-dim: #9ca3af;
    --shadow-premium: 0 20px 40px -15px rgba(0, 0, 0, 0.6);
}

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

body {
    font-family: 'Outfit', 'Cairo', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

[dir="rtl"] {
    font-family: 'Cairo', sans-serif;
}

.glass-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top right, #1a1e26, #0f1115);
    z-index: -1;
}

.glass-bg::before {
    content: '';
    position: absolute;
    top: -10%;
    right: -10%;
    width: 40%;
    height: 40%;
    background: radial-gradient(circle, rgba(193, 168, 125, 0.1) 0%, transparent 70%);
    filter: blur(100px);
}

.container {
    width: 90%;
    max-width: 1000px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

header {
    padding: 24px 40px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    letter-spacing: 1px;
    color: var(--primary);
}

.logo span {
    color: var(--text-main);
    font-weight: 300;
}

.tagline {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: var(--text-dim);
    margin-top: 4px;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.welcome-message {
    text-align: center;
    margin-top: 50px;
}

.welcome-message h2 {
    font-size: 32px;
    margin-bottom: 12px;
    color: var(--accent);
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 30px;
}

.suggestion-chip {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 10px 20px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.suggestion-chip:hover {
    background: rgba(193, 168, 125, 0.2);
    border-color: var(--primary);
}

/* Messages */
.message {
    max-width: 85%;
    padding: 18px 24px;
    border-radius: 20px;
    line-height: 1.6;
    animation: fadeIn 0.4s ease forwards;
}

.user-message {
    align-self: flex-end;
    background: var(--primary);
    color: #000;
    border-bottom-right-radius: 4px;
}

.ai-message {
    align-self: flex-start;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 4px;
    position: relative;
    padding: 32px;
    box-shadow: var(--shadow-premium);
}

.ai-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, var(--primary), transparent);
    border-radius: 4px 0 0 4px;
}

.ai-message.rtl::before {
    left: auto;
    right: 0;
    border-radius: 0 4px 4px 0;
}

.thought-process.collapsible {
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 2px solid var(--primary);
    background: rgba(0, 0, 0, 0.2);
    padding: 0;
    overflow: hidden;
    margin-bottom: 24px;
}

.thought-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-dim);
}

.toggle-icon {
    font-size: 10px;
    transition: transform 0.3s ease;
}

.thought-content {
    max-height: 0;
    overflow: hidden;
    padding: 0 16px;
    transition: all 0.3s ease;
    font-size: 12px;
    color: var(--text-dim);
    opacity: 0;
}

.thought-process.expanded .thought-content {
    max-height: 200px;
    padding: 0 16px 16px 16px;
    opacity: 1;
}

.thought-process.expanded .toggle-icon {
    transform: rotate(180deg);
}

.thought-process:hover {
    background: rgba(193, 168, 125, 0.05);
}

.citations {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.citation-tag {
    font-size: 12px;
    background: rgba(193, 168, 125, 0.15);
    color: var(--primary);
    border: 1px solid rgba(193, 168, 125, 0.3);
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
}

/* Input Area */
.input-area {
    padding: 24px 40px;
    border-top: 1px solid var(--glass-border);
}

.input-wrapper {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 4px;
    transition: border-color 0.3s;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
}

#userInput {
    flex: 1;
    background: transparent;
    border: none;
    padding: 14px 20px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 16px;
}

#userInput:focus {
    outline: none;
}

#sendBtn {
    background: var(--primary);
    color: #000;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

#sendBtn svg {
    width: 20px;
}

/* Loading */
.hidden { display: none !important; }

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 17, 21, 0.9);
    padding: 30px 40px;
    border-radius: 20px;
    text-align: center;
    z-index: 100;
    border: 1px solid var(--glass-border);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--glass-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.modal-content {
    background: #1a1e26;
    padding: 40px;
    border-radius: 24px;
    width: 80%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid var(--glass-border);
}

.close {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 28px;
    cursor: pointer;
}

#modalBody {
    line-height: 1.8;
    margin-top: 20px;
    white-space: pre-wrap;
}

/* RTL Support */
.rtl {
    direction: rtl;
    text-align: right;
}

.ai-message.rtl {
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 4px;
    align-self: flex-start;
}

/* Tiptap Premium Styling */
.tiptap-content {
    outline: none;
}

.tiptap-content h3 {
    font-family: 'Playfair Display', 'Cairo', serif;
    color: var(--primary);
    margin: 32px 0 16px 0;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tiptap-content h3::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, rgba(193, 168, 125, 0.3), transparent);
}

[dir="rtl"] .tiptap-content h3::after {
    background: linear-gradient(to left, rgba(193, 168, 125, 0.3), transparent);
}

.tiptap-content p {
    margin-bottom: 20px;
    line-height: 1.8;
}

.tiptap-content blockquote {
    border-left: 3px solid var(--primary);
    background: rgba(193, 168, 125, 0.03);
    padding: 16px 24px;
    margin: 24px 0;
    border-radius: 4px;
    font-style: normal;
    color: var(--primary-light);
    font-size: 0.95rem;
}

[dir="rtl"] .tiptap-content blockquote {
    border-left: none;
    border-right: 3px solid var(--primary);
}

/* Legal Reference Highlighting */
.legal-ref {
    color: var(--primary);
    font-weight: 600;
    background: rgba(193, 168, 125, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    border-bottom: 1px solid rgba(193, 168, 125, 0.3);
}

/* Executive Summary Highlight */
.tiptap-content h3:first-of-type + p {
    font-size: 1.1rem;
    color: #fff;
    background: rgba(193, 168, 125, 0.05);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(193, 168, 125, 0.1);
}

/* Micro-animations */
.message {
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* Action Buttons for AI Message */
.msg-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s;
}

.ai-message:hover .msg-actions {
    opacity: 1;
}

[dir="rtl"] .msg-actions {
    right: auto;
    left: 12px;
}

.action-btn {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--primary);
    color: #000;
}

.tiptap-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

.tiptap-content th {
    background: rgba(193, 168, 125, 0.1);
    color: var(--primary);
    text-align: right;
    padding: 12px;
    font-size: 14px;
    border-bottom: 1px solid var(--glass-border);
}

.tiptap-content td {
    padding: 12px;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tiptap-content tr:last-child td {
    border-bottom: none;
}

.tiptap-content a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px dashed var(--primary);
}

.tiptap-content em {
    color: var(--accent);
}

