/**
 * Chatwoot PHP Chat - Estilos
 * Baseado no design do WhatsApp Web
 */

/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #d1d7db;
    height: 100vh;
    overflow: hidden;
}

/* Container Principal */
.chat-container {
    display: flex;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ====== SIDEBAR ====== */
.sidebar {
    width: 320px;
    background: #fff;
    border-right: 1px solid #e9edef;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    background: #f0f2f5;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #e9edef;
}

.sidebar-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #00a884;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-avatar svg {
    fill: white;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 600;
    color: #111b21;
}

.sidebar-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.chat-info {
    padding: 16px;
    background: #f0f2f5;
    border-radius: 8px;
    margin-bottom: 16px;
}

.chat-info h3 {
    font-size: 14px;
    font-weight: 600;
    color: #111b21;
    margin-bottom: 8px;
}

.chat-info p {
    font-size: 13px;
    color: #667781;
    line-height: 1.4;
}

.history-section {
    padding: 16px;
    background: #f0f2f5;
    border-radius: 8px;
}

.history-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #111b21;
    margin-bottom: 12px;
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    padding: 10px;
    background: #fff;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.history-item:hover {
    background: #f0f2f5;
}

.history-item-date {
    font-size: 11px;
    color: #8696a0;
}

.history-item-preview {
    font-size: 13px;
    color: #111b21;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-clear {
    width: 100%;
    padding: 10px;
    background: #fff;
    border: 1px solid #00a884;
    color: #00a884;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    transition: all 0.2s;
}

.btn-clear:hover {
    background: #00a884;
    color: #fff;
}

/* ====== CHAT MAIN ====== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #efeae2;
    position: relative;
}

/* Background pattern */
.chat-main::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d1d7db' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.6;
    pointer-events: none;
}

/* ====== CHAT HEADER ====== */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #f0f2f5;
    border-bottom: 1px solid #e9edef;
    position: relative;
    z-index: 10;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #00a884;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-header-details {
    display: flex;
    flex-direction: column;
}

.chat-header-name {
    font-size: 16px;
    font-weight: 600;
    color: #111b21;
}

.chat-header-status {
    font-size: 12px;
    color: #667781;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: #e9edef;
}

/* ====== CHAT MESSAGES ====== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 60px;
    position: relative;
    z-index: 5;
}

.chat-date-divider {
    text-align: center;
    margin: 16px 0;
}

.chat-date-divider span {
    background: rgba(225, 245, 254, 0.9);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    color: #111b21;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chat-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #111b21;
}

.welcome-icon {
    margin-bottom: 16px;
}

.chat-welcome p {
    font-size: 16px;
    margin: 8px 0;
}

/* ====== MESSAGES ====== */
.message {
    max-width: 65%;
    margin-bottom: 4px;
    display: flex;
    flex-direction: column;
    animation: messageSlide 0.3s ease;
}

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

.message-outgoing {
    align-self: flex-end;
    align-items: flex-end;
}

.message-incoming {
    align-self: flex-start;
    align-items: flex-start;
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    color: #00a884;
    margin-bottom: 4px;
    margin-left: 12px;
}

.message-bubble {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 19px;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-outgoing .message-bubble {
    background: #d9fdd3;
    border-top-right-radius: 0;
}

.message-incoming .message-bubble {
    background: #fff;
    border-top-left-radius: 0;
}

.message-time {
    font-size: 11px;
    color: #667781;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.message-outgoing .message-time {
    justify-content: flex-end;
    margin-right: 4px;
}

.message-incoming .message-time {
    margin-left: 4px;
}

.message-check svg {
    width: 14px;
    height: 14px;
}

/* ====== ATTACHMENTS ====== */
.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.message-attachments .attachment img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-attachments .attachment img:hover {
    transform: scale(1.02);
}

.attachment-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    text-decoration: none;
    color: #111b21;
    font-size: 13px;
    transition: background 0.2s;
}

.attachment-file:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* ====== CHAT INPUT ====== */
.chat-input-area {
    padding: 10px 16px;
    background: #f0f2f5;
    position: relative;
    z-index: 10;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border-radius: 8px;
    padding: 8px 12px;
}

.input-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.input-btn:hover {
    background: #f0f2f5;
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    padding: 8px 12px;
    background: transparent;
}

.send-btn {
    background: #00a884;
    width: 44px;
    height: 44px;
}

.send-btn:hover {
    background: #008f6f;
}

/* ====== IMAGE PREVIEW ====== */
.image-preview {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.image-preview.hidden {
    display: none;
}

.preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-content {
    position: relative;
    max-width: 80%;
    max-height: 80%;
}

.preview-content img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 8px;
}

.preview-close,
.preview-send {
    position: absolute;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-close {
    top: -50px;
    right: 0;
    width: 40px;
    height: 40px;
    background: #fff;
    color: #111b21;
}

.preview-send {
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 24px;
    background: #00a884;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

/* ====== SCROLLBAR ====== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* ====== TYPING INDICATOR ====== */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 8px;
    border-top-left-radius: 0;
    width: fit-content;
    margin-left: 12px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #8696a0;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-4px);
    }
}

/* ====== RESPONSIVE ====== */
@media (max-width: 900px) {
    .sidebar {
        display: none;
    }

    .chat-messages {
        padding: 20px 16px;
    }

    .message {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 8px 12px;
    }

    .chat-input-area {
        padding: 8px 12px;
    }

    .message-bubble {
        font-size: 13px;
    }
}
