:root {
    --primary-color: #007bff;
    --primary-light: #e6f2ff;
    --bg-color: #f0f2f5;
    --chat-bg: #e5ddd5;
    --white: #ffffff;
    --dark-text: #111b21;
    --gray-text: #667781;
    --bubble-sent: #d9fdd3;
    --bubble-received: #ffffff;
    --header-height: 60px;
    --input-height: 60px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #111b21;
        --chat-bg: #0b141a;
        --white: #202c33;
        --dark-text: #e9edef;
        --gray-text: #8696a0;
        --bubble-sent: #005c4b;
        --bubble-received: #202c33;
        --primary-color: #53bdeb;
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }

body {
    background-color: var(--bg-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.chat-header {
    height: var(--header-height);
    background-color: var(--white);
    padding: 0 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    z-index: 10;
}

.header-info h1 {
    font-size: 1.1rem;
    color: var(--dark-text);
}

.status-badge {
    font-size: 0.8rem;
    color: var(--gray-text);
}

/* Chat Area */
.chat-container {
    flex: 1;
    background-color: var(--chat-bg);
    /* Optional: pattern background */
    background-image: url("data:image/svg+xml,%3Csvg width='64' height='64' viewBox='0 0 64 64' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8 16c4.418 0 8-3.582 8-8s-3.582-8-8-8-8 3.582-8 8 3.582 8 8 8zm0-2c3.314 0 6-2.686 6-6s-2.686-6-6-6-6 2.686-6 6 2.686 6 6 6zm33.414.6l1.24.83-4 6-1.24-.83 4-6zm-6.828-6.17l-.83 1.24-6-4 .83-1.24 6 4zm-7.98 12.57l-6-4 .83-1.24 6 4-.83 1.24zm20.828.6l-6 4-.83-1.24 6-4 .83 1.24zm-6.828-6.17l4 6-1.24.83-4-6 1.24-.83zM32 48c4.418 0 8-3.582 8-8s-3.582-8-8-8-8 3.582-8 8 3.582 8 8 8zm0-2c3.314 0 6-2.686 6-6s-2.686-6-6-6-6 2.686-6 6 2.686 6 6 6zM8 32c0 4.418 3.582 8 8 8s8-3.582 8-8-3.582-8-8-8-8 3.582-8 8zm2 0c0-3.314 2.686-6 6-6s6 2.686 6 6-2.686 6-6 6-6-2.686-6-6zm-2 22c4.418 0 8-3.582 8-8s-3.582-8-8-8-8 3.582-8 8 3.582 8 8 8zm0-2c3.314 0 6-2.686 6-6s-2.686-6-6-6-6 2.686-6 6 2.686 6 6 6zm54-2c0 4.418 3.582 8 8 8s8-3.582 8-8-3.582-8-8-8-8 3.582-8 8zm-2 0c0 3.314-2.686 6-6 6s-6-2.686-6-6 2.686-6 6-6 6 2.686 6 6z' fill='%239ca3af' fill-opacity='0.08' fill-rule='evenodd'/%3E%3C/svg%3E");
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.95rem;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    word-wrap: break-word;
    margin-bottom: 2px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.msg-sent {
    background-color: var(--bubble-sent);
    align-self: flex-end;
    border-top-right-radius: 2px;
    color: var(--dark-text);
}

.msg-received {
    background-color: var(--bubble-received);
    align-self: flex-start;
    border-top-left-radius: 2px;
    color: var(--dark-text);
}

.msg-time {
    font-size: 0.7rem;
    color: var(--gray-text);
    display: block;
    text-align: right;
    margin-top: 4px;
    margin-left: 8px;
}

.msg-media {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 4px;
    display: block;
}

.msg-video {
    max-width: 100%;
    border-radius: 8px;
}

/* Input Area */
.chat-input-area {
    min-height: var(--input-height);
    background-color: var(--white);
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#message-form {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.btn-icon {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--gray-text);
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-icon:hover {
    background-color: rgba(0,0,0,0.05);
}

.send-btn {
    color: var(--primary-color);
}

#message-input {
    flex: 1;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 1rem;
    outline: none;
    background-color: var(--bg-color);
    color: var(--dark-text);
}

/* File Preview */
.file-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-color);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--dark-text);
}

.hidden { display: none; }

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: var(--white);
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
}

.modal-content h3 {
    margin-bottom: 16px;
    color: var(--dark-text);
}

#ticket-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
}

#ticket-list li {
    padding: 12px;
    border-bottom: 1px solid var(--bg-color);
    cursor: pointer;
    color: var(--dark-text);
}

#ticket-list li:hover {
    background-color: var(--bg-color);
}

.btn-primary {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}
