@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-ExtraBold.woff2') format('woff2');
    font-weight: 800 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-body: #060709;
    --bg-card: rgba(18, 20, 26, 0.7);
    --bg-card-border: rgba(255, 255, 255, 0.08);
    --primary: #ffc107;
    --primary-gradient: linear-gradient(135deg, #ffd54f 0%, #ffb300 100%);
    --accent-glow: rgba(255, 193, 7, 0.12);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --user-msg-bg: linear-gradient(135deg, #232730 0%, #191c23 100%);
    --ai-msg-bg: rgba(15, 17, 23, 0.75);
    --radius-lg: 20px;
    --radius-md: 14px;
    --font: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
    --link-color: #ff453a;
    --link-hover: #ff6961;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: var(--font);
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
    background: 
        radial-gradient(circle at 50% 0%, rgba(255, 193, 7, 0.08), transparent 45%),
        radial-gradient(circle at 100% 100%, rgba(139, 92, 246, 0.03), transparent 40%),
        var(--bg-body);
}

/* App Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    position: relative;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(6, 7, 9, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--bg-card-border);
    z-index: 20;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.brand-title {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.2px;
    background: linear-gradient(to right, #fff, #d1d5db);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.btn-new-chat {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--bg-card-border);
    color: var(--text-main);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-new-chat:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

/* Chat Scroll Area */
.chat-viewport {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px 140px;
    scroll-behavior: smooth;
}

/* سفارشی‌سازی اسکرول‌بار برای مرورگرهای Chrome, Safari, Edge و Opera */
.chat-viewport::-webkit-scrollbar {
    width: 4px; /* باریک‌تر کردن عرض اسکرول‌بار */
}

.chat-viewport::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02); /* رنگ پس‌زمینه مسیر اسکرول */
}

.chat-viewport::-webkit-scrollbar-thumb {
    background: rgba(255, 193, 7, 0.3); /* رنگ طلایی کم‌رنگ برای میله اسکرول */
    border-radius: 10px; /* گرد کردن لبه‌ها */
}

.chat-viewport::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 193, 7, 0.7); /* پررنگ‌تر شدن هنگام قرار گرفتن موس روی آن */
}

/* سفارشی‌سازی اسکرول‌بار برای مرورگر Firefox */
.chat-viewport {
    scrollbar-width: thin; /* باریک کردن */
    scrollbar-color: rgba(255, 193, 7, 0.3) transparent; /* رنگ میله و پس‌زمینه */
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    text-align: center;
    animation: fadeIn 0.4s ease;
}

.welcome-badge {
    width: 72px;
    height: 72px;
    border-radius: 22px;
    object-fit: cover;
    border: 1px solid rgba(255, 193, 7, 0.3);
    box-shadow: 0 12px 35px var(--accent-glow);
    margin-bottom: 20px;
}

.welcome-screen h1 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 8px;
    color: #ffffff;
}

.welcome-screen p {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 420px;
    line-height: 1.7;
    margin-bottom: 28px;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 520px;
}

.suggestion-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    color: #d1d5db;
    font-size: 12px;
    text-align: right;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.suggestion-card:hover {
    border-color: rgba(255, 193, 7, 0.4);
    background: rgba(255, 193, 7, 0.05);
    color: #fff;
    transform: translateY(-2px);
}

/* Messages */
.message-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 18px;
    animation: messageSlide 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
}

.message-row.user { align-items: flex-start; }
.message-row.assistant { align-items: flex-end; }

.message-bubble {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.85;
    position: relative;
    word-break: break-word;
}

.message-row.user .message-bubble {
    background: var(--user-msg-bg);
    color: #f9fafb;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-top-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.message-row.assistant .message-bubble {
    background: var(--ai-msg-bg);
    border: 1px solid var(--bg-card-border);
    color: #e5e7eb;
    border-top-left-radius: 4px;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 100%;
}

/* Links & Typography */
.message-bubble a {
    color: var(--link-color);
    text-decoration: none !important;
    font-weight: 700;
    transition: color 0.2s ease;
}

.message-bubble a:hover {
    color: var(--link-hover);
}

.message-bubble strong { color: var(--primary); font-weight: 700; }
.message-bubble em { color: #f3f4f6; font-style: italic; }
.message-bubble p { margin-bottom: 10px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble ul, .message-bubble ol { margin: 8px 0; padding-right: 20px; }
.message-bubble li { margin-bottom: 4px; }
.message-bubble code {
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 12px;
    color: #f59e0b;
    font-family: monospace;
    dir: ltr;
}

/* Copy Button */
.msg-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.04);
}

.btn-copy {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: inherit;
    transition: color 0.2s;
}
.btn-copy:hover { color: var(--primary); }

/* Typing Dots */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 4px;
}
.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

@keyframes messageSlide {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Floating Input Bar */
.input-dock {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px 20px;
    background: linear-gradient(to top, var(--bg-body) 60%, rgba(6,7,9,0));
    z-index: 30;
}

.input-box {
    background: rgba(18, 20, 26, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-lg);
    padding: 6px 8px 6px 14px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
    transition: border-color 0.2s;
}

.input-box:focus-within {
    border-color: rgba(255, 193, 7, 0.5);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
    max-height: 120px;
    min-height: 40px;
    resize: none;
    padding: 8px 0;
}

textarea::placeholder { color: #6b7280; }

.btn-send {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--primary-gradient);
    border: none;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.2);
}

.btn-send:hover {
    transform: scale(1.04);
    box-shadow: 0 6px 16px rgba(255, 193, 7, 0.35);
}

.btn-send:active { transform: scale(0.95); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-send svg {
    width: 18px;
    height: 18px;
    fill: #000;
    transform: rotate(180deg);
}

.disclaimer {
    text-align: center;
    font-size: 10px;
    color: #4b5563;
    margin-top: 8px;
}

/* Responsive Mobile Adjustments */
@media (max-width: 640px) {
    .suggestions-grid { grid-template-columns: 1fr; }
    .message-bubble { max-width: 90%; font-size: 13.5px; }
    .welcome-screen h1 { font-size: 20px; }
    .welcome-screen p { font-size: 12px; }
    .input-dock { padding: 8px 12px 14px; }
}