* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --whatsapp-green: #25D366;
    --whatsapp-dark-green: #128C7E;
    --whatsapp-teal: #075E54;
    --light-green: #DCF8C6;
    --light-gray: #f0f2f5;
    --chat-bg: #efeae2;
    --header-bg: #f0f2f5;
    --border-color: #e9edef;
    --text-muted-custom: #667781;
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(180deg, #00a884 0%, #00a884 127px, #e5e5e5 127px, #e5e5e5 100%);
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
}

.min-w-0 {
    min-width: 0 !important;
}

/* Contenedor principal */
.chat-layout {
    display: flex;
    width: 100%;
    height: calc(100vh - 103px);
    min-height: calc(100vh - 0px);
    overflow: hidden;
    background-color: #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
}

/* Sidebar */
.sidebar,
.chat-sidebar {
    width: 30%;
    min-width: 320px;
    max-width: 420px;
    background-color: #fff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Área de chat */
.chat-area,
.chat-main {
    flex: 1;
    min-width: 0;
    background-color: var(--chat-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-area-placeholder {
    background-color: var(--chat-bg);
}

/* Header */
.chat-header,
.sidebar-header {
    background-color: var(--header-bg);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    min-height: 60px;
    flex-shrink: 0;
}

/* Avatar */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-lg {
    width: 50px;
    height: 50px;
}

.avatar-sm {
    width: 30px;
    height: 30px;
}

/* Indicador en línea */
.online-indicator {
    width: 10px;
    height: 10px;
    background-color: #31a24c;
    border-radius: 50%;
    border: 2px solid white;
    position: absolute;
    bottom: 2px;
    right: 2px;
}

/* Lista de contactos */
.contact-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.contact-item:hover {
    background-color: #f5f6f6;
}

.contact-item.active {
    background-color: #f0f2f5;
}

.chat-preview-text {
    max-width: 180px;
    display: inline-block;
}

/* Search */
.search-box {
    padding: 8px 12px;
    background-color: white;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.search-icon {
    left: 15px;
    top: 12px;
}

.search-input {
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 20px;
    background-color: #f0f2f5;
    outline: none;
}

.search-input:focus {
    background-color: #e5e5e5;
}

.search-results {
    position: absolute;
    left: 12px;
    right: 12px;
    top: calc(100% - 2px);
    z-index: 30;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
    max-height: 320px;
    overflow-y: auto;
}

/* Contenedor de mensajes */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-height: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 32 32' opacity='0.05'><circle fill='%23333' cx='16' cy='16' r='2'/></svg>");
}

/* Burbujas */
.message {
    display: flex;
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease;
    width: 100%;
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-content {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 7.5px;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message.sent .message-content {
    background-color: #d9fdd3;
    border-top-right-radius: 0;
}

.message.received .message-content {
    background-color: white;
    border-top-left-radius: 0;
}

.message-content .chat-text,
.message-content p {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.45;
}

.message-time {
    font-size: 11px;
    color: #667781;
    margin-top: 4px;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.message-status {
    font-size: 12px;
    color: #53bdeb;
}

/* Input */
.message-input-area {
    background-color: var(--header-bg);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.message-input {
    flex: 1;
    min-width: 0;
    border: none;
    border-radius: 20px;
    padding: 10px 15px;
    outline: none;
    background-color: white;
}

.message-input:focus {
    box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.2);
}

/* Botones */
.btn-icon {
    background: none;
    border: none;
    color: #54656f;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-send {
    color: var(--whatsapp-green);
}

.btn-send:hover {
    color: var(--whatsapp-dark-green);
}

/* Archivos */
.file-preview,
.chat-media-image {
    max-width: 250px;
    max-height: 250px;
    width: 100%;
    border-radius: 7.5px;
    margin-bottom: 5px;
    cursor: pointer;
    object-fit: cover;
}

.file-preview.video,
.chat-media-video {
    max-width: 300px;
    max-height: 300px;
    width: 100%;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typing {
    0% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.3;
    }
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px;
    background-color: white;
    border-radius: 18px;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #8696a0;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* Loading */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--whatsapp-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #8696a0;
    text-align: center;
    padding: 20px;
}

.empty-state i {
    font-size: 60px;
    margin-bottom: 20px;
    color: #d1d7db;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background-color: white;
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-left: 4px solid #25D366;
}

.toast.error {
    border-left: 4px solid #f44336;
}

.toast.warning {
    border-left: 4px solid #ff9800;
}

.toast.info {
    border-left: 4px solid #2196f3;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Formularios */
.form-control:focus {
    color: #212121 !important;
    background-color: #fff !important;
    border-color: #15913a !important;
    outline: 0 !important;
    box-shadow: 0 0 0 .25rem rgba(13, 254, 53, 0.25) !important;
}

.form-select:focus {
    box-shadow: 0 0 0 .25rem rgba(13, 254, 53, 0.25) !important;
}

.form-check-input:checked {
    background-color: #15913a;
    border-color: #0dfd1d;
}

.menssage-chat {
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-chat {
    color: #fff;
    background: linear-gradient(135deg, #00a884 0%, #128c7e 100%);
    border-color: #198754;
}

.btn-chat:hover {
    color: #fff;
    background: linear-gradient(135deg, #128c7e 0%, #0b6f61 100%);
    border-color: #157347;
}

/* Tablet */
@media (max-width: 991.98px) {
    .sidebar,
    .chat-sidebar {
        width: 330px;
        min-width: 300px;
    }

    .message-content {
        max-width: 78%;
    }
}

/* Móvil */
@media (max-width: 767.98px) {
    body {
        background: #e5e5e5;
    }

    .chat-layout {
        height: 100vh;
        min-height: 100vh;
        box-shadow: none;
    }

    .sidebar,
    .chat-sidebar {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        border-right: none;
    }

    .chat-area,
    .chat-main {
        width: 100%;
    }

    .sidebar-header,
    .chat-header,
    .message-input-area {
        padding-left: 12px;
        padding-right: 12px;
    }

    .messages-container {
        padding: 12px 10px;
    }

    .message-content {
        max-width: 88%;
        padding: 8px 10px;
    }

    .chat-media-image,
    .chat-media-video,
    .file-preview {
        max-width: 100%;
        max-height: 240px;
    }

    .chat-preview-text {
        max-width: 140px;
    }

    .search-results {
        left: 10px;
        right: 10px;
    }
    
}

/* Móvil pequeño */
@media (max-width: 480px) {
    .message-content {
        max-width: 92%;
    }

    .avatar {
        width: 36px;
        height: 36px;
    }

    .message-input {
        padding: 10px 14px;
        font-size: 13px;
    }

    .btn-icon {
        width: 38px;
        height: 38px;
    }

    .chat-preview-text {
        max-width: 110px;
    }
}