﻿* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Tahoma, 'Segoe UI', sans-serif;
    background: #F3F4F6;
    color: #111827;
    direction: rtl;
    min-height: 100vh;
}

/* ═══ Login ═══ */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4F46E5, #7C3AED);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    text-align: center;
}

.login-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #4F46E5, #7C3AED);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
}

.login-card h1 {
    font-size: 20px;
    margin-bottom: 6px;
    color: #111827;
}

.login-sub {
    color: #6b7280;
    font-size: 13px;
    margin-bottom: 24px;
}

.login-card input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #E5E7EB;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 14px;
    outline: none;
    transition: border-color 0.15s;
}

    .login-card input:focus {
        border-color: #4F46E5;
    }

.login-card button {
    width: 100%;
    padding: 12px;
    background: #4F46E5;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

    .login-card button:hover:not(:disabled) {
        background: #4338CA;
    }

    .login-card button:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

/* ═══ Errors ═══ */
.error-box {
    background: #FEE2E2;
    color: #991B1B;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 14px;
    text-align: right;
}

.hidden {
    display: none !important;
}

/* ═══ Topbar ═══ */
.topbar {
    background: #fff;
    border-bottom: 1px solid #E5E7EB;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 15px;
}

.topbar-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #4F46E5, #7C3AED);
    color: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-btn {
    background: #F3F4F6;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    color: #374151;
}

    .topbar-btn:hover {
        background: #E5E7EB;
    }

.unread-badge {
    background: #EF4444;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
}

/* ═══ Container ═══ */
.container {
    display: flex;
    height: calc(100vh - 61px);
}

/* ═══ Sidebar ═══ */
.sidebar {
    width: 320px;
    background: #fff;
    border-left: 1px solid #E5E7EB;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .sidebar-header h3 {
        font-size: 14px;
        color: #111827;
    }

.btn-icon {
    background: #F3F4F6;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

    .btn-icon:hover {
        background: #E5E7EB;
    }

.ticket-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.ticket-item {
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: background 0.12s;
    border-right: 3px solid transparent;
}

    .ticket-item:hover {
        background: #F9FAFB;
    }

    .ticket-item.active {
        background: #EEF2FF;
        border-right-color: #4F46E5;
    }

    .ticket-item.has-unread {
        border-right-color: #EF4444;
    }

.ticket-name {
    font-weight: 600;
    font-size: 13px;
    color: #111827;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ticket-badge {
    background: #EF4444;
    color: #fff;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 8px;
    font-weight: 700;
}

.ticket-preview {
    font-size: 11.5px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ticket-time {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 4px;
}

.loading {
    padding: 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

/* ═══ Chat ═══ */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #F9FAFB;
}

.chat-header {
    padding: 16px 20px;
    background: #fff;
    border-bottom: 1px solid #E5E7EB;
    min-height: 62px;
    display: flex;
    align-items: center;
}

.chat-empty-text {
    color: #6b7280;
    font-size: 13px;
}

.chat-ticket-title {
    font-weight: 700;
    font-size: 14px;
    color: #111827;
}

.chat-ticket-meta {
    font-size: 11.5px;
    color: #6b7280;
    margin-top: 2px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 13px;
    gap: 12px;
}

.chat-empty-icon {
    font-size: 48px;
    opacity: 0.4;
}

.msg-row {
    display: flex;
}

    .msg-row.in {
        justify-content: flex-start;
    }

    .msg-row.out {
        justify-content: flex-end;
    }

.msg-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.7;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    word-wrap: break-word;
}

    .msg-bubble.in {
        background: #fff;
        border: 1px solid #E5E7EB;
        border-bottom-right-radius: 4px;
    }

    .msg-bubble.out {
        background: linear-gradient(135deg, #4F46E5, #6366F1);
        color: #fff;
        border-bottom-left-radius: 4px;
    }

.msg-sender {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #4F46E5;
}

.msg-bubble.out .msg-sender {
    color: rgba(255,255,255,0.9);
}

.msg-time {
    font-size: 10px;
    margin-top: 5px;
    opacity: 0.7;
    direction: ltr;
    text-align: left;
}

.chat-input-bar {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #E5E7EB;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

    .chat-input-bar textarea {
        flex: 1;
        border: 1.5px solid #E5E7EB;
        border-radius: 10px;
        padding: 10px 14px;
        font-family: inherit;
        font-size: 13px;
        line-height: 1.6;
        resize: none;
        max-height: 120px;
        outline: none;
        transition: border-color 0.15s;
    }

        .chat-input-bar textarea:focus {
            border-color: #4F46E5;
        }

        .chat-input-bar textarea:disabled {
            background: #F9FAFB;
            cursor: not-allowed;
        }

    .chat-input-bar button {
        background: #4F46E5;
        color: #fff;
        border: none;
        border-radius: 10px;
        padding: 10px 24px;
        font-family: inherit;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        height: 42px;
    }

        .chat-input-bar button:hover:not(:disabled) {
            background: #4338CA;
        }

        .chat-input-bar button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }
.ticket-customer {
    font-size: 11px;
    color: #6366F1;
    margin-bottom: 4px;
    font-weight: 500;
}

.ticket-time code {
    background: #F3F4F6;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 9px;
    direction: ltr;
    color: #9ca3af;
}

.msg-bubble {
    position: relative;
}

.msg-del-btn {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,0.08);
    border: none;
    color: #6b7280;
    font-size: 11px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msg-bubble:hover .msg-del-btn {
    opacity: 1;
}

.msg-del-btn:hover {
    background: #EF4444;
    color: #fff;
}