/* Estilos generales */
.chat-management-container {
    display: flex;
    height: 100vh;
    box-sizing: border-box;
    position: relative;
    background-color: var(--background-sidebar);
}

main {
    margin: 0;
}

/* Sidebar */
.sidebar {
    width: 300px;
    box-sizing: border-box;
    border-right: 1px solid var(--line-gray-color);
    display: flex;
    flex-direction: column;
    background-color: var(--white-color);
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--line-gray-color);
    background-color: var(--white-color);
}

.sidebar-header h3 {
    margin: 0 0 1rem 0;
    color: var(--text-color-black);
    font-size: 1.2rem;
    font-weight: 500;
}

.user-info {
    margin-bottom: 1rem;
    padding: 0.5rem;
    background-color: var(--background-sidebar);
    border-radius: 4px;
}

.user-name {
    font-weight: 500;
    color: var(--text-color-black);
    font-size: 0.9rem;
}

.filter-controls {
    margin-bottom: 1rem;
}

.form-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--line-gray-color);
    border-radius: 4px;
    background-color: var(--white-color);
    font-size: 0.9rem;
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.chat-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--line-gray-color);
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
    margin-bottom: 0.25rem;
}

.chat-item:hover {
    background-color: var(--nav-link-active);
}

.chat-item.selected {
    background-color: var(--primary-color-hex);
    color: var(--white-color);
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.phone-number {
    font-weight: 500;
    color: var(--text-color-black);
    font-size: 0.9rem;
}

.chat-status {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.chat-status::before {
    content: "";
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
}

.chat-status.initial::before {
    background-color: var(--primary-color-hex);
}

.chat-status.waiting_advisor::before {
    background-color: var(--color-warning);
}

.chat-status.with_advisor::before {
    background-color: var(--color-success);
}

.chat-status.closed::before {
    background-color: var(--color-danger);
}

.chat-item-body {
    margin-bottom: 0.75rem;
}

.last-message {
    color: var(--text-color-gray);
    font-size: 0.85rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-item-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-color-gray-secondary);
    margin-top: 0.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--white-color);
}

.no-chat-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-color-gray);
    text-align: center;
    padding: 2rem;
}

.no-chat-selected i {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color-hex);
    opacity: 0.5;
}

.no-chat-selected h3 {
    font-size: 1.5rem;
    font-weight: 500;
}

/* Chat Detail */
.chat-detail {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 1rem;
    border-bottom: 1px solid var(--line-gray-color);
    background-color: var(--white-color);
}

.customer-info {
    margin-bottom: 1.5rem;
}

.customer-info h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-color-black);
    font-size: 1rem;
    font-weight: 500;
}

.customer-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--primary-color-hex);
    margin: 0 0 0.5rem 0;
}

.customer-email,
.customer-phone {
    margin: 0.25rem 0;
    color: var(--text-color-gray);
    font-size: 0.85rem;
}

.customer-email i,
.customer-phone i {
    margin-right: 0.75rem;
    color: var(--primary-color-hex);
    font-size: 1.1rem;
}

.chat-actions {
    display: flex;
    gap: 1rem;
}

.action-button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: Inter, Helvetica, Arial, sans-serif;
}

.action-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.action-button.take-support {
    background-color: var(--primary-color-hex);
    color: var(--white-color);
}

.action-button.close-chat {
    background-color: var(--color-danger);
    color: var(--white-color);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background-color: var(--background-sidebar);
}

.message {
    max-width: 70%;
    padding: 0.75rem;
    border-radius: 8px;
    position: relative;
}

.message.customer {
    align-self: flex-start;
    background-color: var(--white-color);
    color: var(--text-color-black);
}

.message.advisor {
    align-self: flex-end;
    background-color: var(--primary-color-hex);
    color: var(--white-color);
}

.message-content {
    margin-bottom: 0.25rem;
    line-height: 1.4;
    font-size: 0.9rem;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-color-gray-secondary);
    text-align: right;
}

.message-input {
    padding: 1rem;
    border-top: 1px solid var(--line-gray-color);
    display: flex;
    gap: 0.5rem;
    background-color: var(--white-color);
}

.message-input textarea {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--line-gray-color);
    border-radius: 4px;
    resize: none;
    height: 40px;
    font-size: 0.9rem;
}

.send-button {
    background-color: var(--primary-color-hex);
    color: var(--white-color);
    border: none;
    border-radius: 4px;
    width: 40px;
    height: 40px;
    font-family: Inter, Helvetica, Arial, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* No chats message */
.no-chats {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 1.1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-management-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 100vh;
        position: fixed;
        left: 0;
        top: 0;
        z-index: 20;
        transform: translateX(0);
        transition: transform 0.3s ease-in-out;
    }

    .sidebar.hidden {
        transform: translateX(-100%);
    }

    .main-content {
        width: 100%;
        height: 100vh;
    }

    .back-button {
        font-family: Inter, Helvetica, Arial, sans-serif;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        margin: 0.5rem;
    }

    .chat-header {
        padding: 1rem;
    }

    .customer-info h4 {
        font-size: 1.1rem;
    }

    .customer-name {
        font-size: 1.1rem;
    }

    .message {
        max-width: 90%;
    }

    .message-input {
        padding: 1rem;
    }
}

@media (min-width: 769px) {
    .back-button {
        display: none;
    }
}

.message-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: 8px;
    margin: 5px 0;
}

.message-audio {
    width: 250px;
    margin: 5px 0;
}

.file-upload {
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.file-upload:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.file-upload input[type="file"] {
    display: none;
}

.selected-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    background-color: var(--background-input-pos);
    border-radius: 8px;
    margin-top: 8px;
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background-color: var(--background-sidebar);
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.file-preview img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.file-preview i {
    font-size: 20px;
    color: #666;
}

.file-preview span {
    font-size: 14px;
    color: var(--text-color-black);
}

.file-preview button {
    background: none;
    border: none;
    color: var(--text-color-gray);
    cursor: pointer;
    font-family: Inter, Helvetica, Arial, sans-serif;
    padding: 0 4px;
    font-size: 18px;
}

.file-preview button:hover {
    color: var(--color-danger);
}

.input-actions {
    display: flex;
    gap: 8px;
    padding: 8px;
}

.input-wrapper {
    display: flex;
    gap: 8px;
    padding: 8px;
    background-color: var(--background-sidebar);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    resize: none;
    padding: 8px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    background-color: var(--input-backgraund-color);
    color: var(--text-color-black);
}

.input-wrapper textarea:focus {
    outline: none;
}

.input-wrapper button {
    background: none;
    border: none;
    color: var(--primary-color-hex);
    font-family: Inter, Helvetica, Arial, sans-serif;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.input-wrapper button:hover {
    background-color: var(--primary-color-hex);
    opacity: 0.1;
}

.input-wrapper button:disabled {
    color: var(--text-color-gray-secondary);
    cursor: not-allowed;
}

/* No messages state */
.no-messages {
    padding: 2rem;
}

.no-messages i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.no-messages p {
    font-size: 0.9rem;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: var(--white-color);
    border-radius: 8px;
    margin-top: 0.5rem;
    font-size: 0.8rem;
}

.typing-dots span {
    width: 6px;
    height: 6px;
}

/* Disabled states */
.message-input textarea:disabled {
    background-color: var(--background-sidebar);
    cursor: not-allowed;
    opacity: 0.7;
}

.send-button:disabled {
    background-color: var(--text-color-gray-secondary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.send-button:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Loading states */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid var(--primary-color-hex);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 11;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Message animations */
.message {
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat List Improvements */
.chat-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: transparent;
    transition: background-color 0.3s;
}

.chat-item.urgent::before {
    background-color: var(--color-warning);
}


.chat-item-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.urgent-badge {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background-color: var(--color-warning);
    color: var(--white-color);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    animation: pulse 2s infinite;
}

.urgent-badge i {
    font-size: 0.8rem;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
    100% {
        opacity: 1;
    }
}

.chat-item-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-item-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
}

.chat-item-meta i {
    font-size: 0.9rem;
    color: var(--text-color-gray);
}

.unread-badge {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background-color: var(--primary-color-hex);
    color: var(--white-color);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.unread-badge i {
    font-size: 0.6rem;
}

/* Chat status improvements */
.chat-status {
    position: relative;
    padding-left: 1rem;
}

.chat-status::before {
    content: "";
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
}

.chat-status.initial::before {
    background-color: var(--primary-color-hex);
}

.chat-status.waiting_advisor::before {
    background-color: var(--color-warning);
}

.chat-status.with_advisor::before {
    background-color: var(--color-success);
}

.chat-status.closed::before {
    background-color: var(--color-danger);
}

/* Responsive improvements for chat list */
@media (max-width: 768px) {
    .chat-item-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .urgent-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }

    .chat-item-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .unread-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
}

.advisor {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-color-gray-secondary);
    font-size: 0.85rem;
}

.advisor i {
    color: var(--primary-color-hex);
}

/* Botones de acción */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: Inter, Helvetica, Arial, sans-serif;
}

.btn-primary {
    background-color: var(--primary-color-hex);
    color: var(--white-color);
}

.btn-primary:hover {
    background-color: var(--primary-color-hex-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-success {
    background-color: var(--color-success);
    color: var(--white-color);
}

.btn-success:hover {
    background-color: var(--color-success-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-danger {
    background-color: var(--color-danger);
    color: var(--white-color);
}

.btn-danger:hover {
    background-color: var(--color-danger-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Estilos específicos para los botones del chat */
.register-customer {
    margin-top: 0.5rem;
    border: none;
}

.take-support {
    margin-right: 0.5rem;
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

