:root {
    --bg-main: #0b0f19;
    --card-bg: rgba(18, 24, 38, 0.85);
    --card-border: rgba(255, 255, 255, 0.08);
    --primary: #f97316;
    --primary-glow: rgba(249, 115, 22, 0.35);
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --bubble-customer: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    --bubble-brand: rgba(30, 41, 59, 0.85);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    background-image:
            radial-gradient(circle at 15% 15%, rgba(249, 115, 22, 0.08) 0%, transparent 40%),
            radial-gradient(circle at 85% 85%, rgba(14, 165, 233, 0.06) 0%, transparent 40%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-light);
    padding: 12px;
}

.chat-app-container {
    width: 100%;
    max-width: 460px;
    height: 94vh;
    max-height: 820px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* بخش احراز هویت / دریافت شماره */
#authSection {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 24px;
    text-align: center;
}

.auth-brand-logo {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: #1e293b;
    border: 2px solid rgba(255, 255, 255, 0.1);
    padding: 4px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    margin-bottom: 16px;
    object-fit: cover;
}

.auth-title {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 6px;
}

.auth-desc {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 24px;
    max-width: 300px;
}

.auth-form {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.custom-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 13px 16px;
    border-radius: 14px;
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: all 0.25s;
    text-align: right;
}

.custom-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.custom-input::placeholder {
    color: #64748b;
}

.btn-submit {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 13px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px var(--primary-glow);
    transition: all 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-submit:hover {
    opacity: 0.95;
    transform: translateY(-2px);
}

.name-fields-box {
    display: none;
    flex-direction: column;
    gap: 10px;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* بخش چت‌روم اصلی */
#chatSection {
    display: none;
    flex-direction: column;
    height: 100%;
}

/* هدر چت */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--card-border);
    background: rgba(15, 23, 42, 0.6);
}

.header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-wrap {
    position: relative;
}

.header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.1);
}

.online-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 11px;
    height: 11px;
    background: #22c55e;
    border: 2px solid #0f172a;
    border-radius: 50%;
}

.header-info h4 {
    font-size: 14px;
    font-weight: 700;
}

.header-info span {
    font-size: 11px;
    color: #22c55e;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* بدنه چت */
.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

/* حباب پیام‌ها */
.msg-row {
    display: flex;
    width: 100%;
}

.msg-row.customer {
    justify-content: flex-start; /* پیام‌های مشتری سمت راست/شروع */
}

.msg-row.brand {
    justify-content: flex-end; /* پاسخ برند */
}

.msg-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    position: relative;
    word-break: break-word;
    line-height: 1.6;
    font-size: 13.5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.msg-row.customer .msg-bubble {
    background: var(--bubble-customer);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.msg-row.brand .msg-bubble {
    background: var(--bubble-brand);
    border: 1px solid var(--card-border);
    color: #f1f5f9;
    border-bottom-left-radius: 4px;
}

.msg-time {
    display: block;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
    text-align: left;
    direction: ltr;
}

/* پیشنهادهای سریع (Quick Chips) */
.quick-chips {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    overflow-x: auto;
    white-space: nowrap;
    background: rgba(15, 23, 42, 0.4);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.quick-chips::-webkit-scrollbar { display: none; }

.chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11.5px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chip:hover {
    color: #fff;
    border-color: var(--primary);
    background: rgba(249, 115, 22, 0.1);
}

/* فوتر و فیلد ورودی */
.chat-footer {
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.8);
    border-top: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 14px;
    border-radius: 14px;
    color: #fff;
    font-size: 13.5px;
    outline: none;
    resize: none;
    max-height: 100px;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--primary);
}

.btn-send {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: var(--primary);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--primary-glow);
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-send:hover {
    transform: scale(1.05);
}