/**
 * REDPRO Chat Styles
 *
 * Styles for the chat system interface.
 */

/* ========================================
   CSS Variables - Global Colors
   ======================================== */

:root {
    /* Colores globales del tema */
    --prord-color-primary: #182E52;
    --prord-color-secondary: #100F0C;
    --prord-color-text: #100F0C;
    --prord-color-accent: #104279;
    --prord-color-accent-alt: #182F53;
    --prord-color-highlight: #72C6CD;
    --prord-color-light: #C4E4E4;
    --prord-color-dark: #1E1B18;

    /* Colores adicionales del tema */
    --prord-color-bg-light: #F8F8F9;
    --prord-color-white: #FFFFFF;
    --prord-color-transparent: #FFFFFF00;
    --prord-color-muted: #718DA3;
    --prord-color-teal: #0C786F;
    --prord-color-gray: #E0E0E0;
    --prord-color-gray-dark: #CDCDCD;
    --prord-color-black: #020101;

    /* Colores específicos del chat */
    --prord-chat-bg: #fff;
    --prord-chat-border: #e0e0e0;
    --prord-chat-bg-alt: #f9f9f9;
    --prord-chat-text-muted: #666;
    --prord-chat-text-light: #999;
    --prord-chat-error: #d63638;
    --prord-chat-success: #46b450;
}

/* ========================================
   Chat Wrapper & Container
   ======================================== */

.prord-chat-wrapper,
.prord-chats-wrapper {
    max-width: 100%;
}

.prord-chat-container,
.prord-chats-container {
    background: var(--prord-chat-bg);
    border-radius: 12px;
    border: 1px solid #ededed;
    overflow: hidden;
}

/* ========================================
   Chat Header
   ======================================== */

.prord-chat-header {
    background: var(--prord-chat-bg);
    border-bottom: 1px solid var(--prord-chat-border);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.prord-chat-header-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.prord-back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f5f5f5;
    color: var(--prord-color-text);
    text-decoration: none;
    transition: background 0.2s;
}

.prord-back-button:hover {
    background: var(--prord-chat-border);
}

.prord-back-button .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.prord-chat-header img {
    border-radius: 50%;
}

.prord-chat-header-info h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--prord-color-text);
}

.prord-user-role {
    font-size: 13px;
    color: var(--prord-chat-text-muted);
}

/* ========================================
   Messages Container
   ======================================== */

.prord-chat-messages {
    height: 500px;
    overflow-y: auto;
    padding: 20px;
    background: var(--prord-chat-bg-alt);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.prord-no-messages {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--prord-chat-text-light);
    text-align: center;
}

/* ========================================
   Message Bubbles
   ======================================== */

.prord-message {
    display: flex;
    gap: 8px;
    max-width: 70%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.prord-message-own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.prord-message-other {
    align-self: flex-start;
}

.prord-message-avatar {
    flex-shrink: 0;
}

.prord-message-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.prord-message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.prord-message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.4;
}

.prord-message-bubble a {
    color: #fff;
    text-decoration: underline;
}

.prord-message-own .prord-message-bubble {
    background: var(--prord-color-accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.prord-message-other .prord-message-bubble {
    background: var(--prord-chat-bg);
    color: var(--prord-color-text);
    border: 1px solid var(--prord-chat-border);
    border-bottom-left-radius: 4px;
}

.prord-message-time {
    font-size: 11px;
    color: var(--prord-chat-text-light);
    padding: 0 8px;
}

.prord-message-own .prord-message-time {
    text-align: right;
}

/* ========================================
   Message Input
   ======================================== */

.prord-chat-input-wrapper {
    background: var(--prord-chat-bg);
    border-top: 1px solid var(--prord-chat-border);
    padding: 16px 20px;
}

.prord-chat-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    width: 100%;
}

.prord-message-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    min-height: 44px;
    max-height: 120px;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 22px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    overflow-y: auto;
    transition: border-color 0.2s;
}

.prord-message-input:focus {
    outline: none;
    border-color: var(--prord-color-accent);
}

.prord-send-button {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    border-radius: 50% !important;
    background: var(--prord-color-accent) !important;
    color: #fff !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
    padding: 0 !important;
    box-shadow: none !important;
}

.prord-send-button:hover {
    background: var(--prord-color-primary) !important;
}

.prord-send-button:disabled {
    background: #ccc !important;
    cursor: not-allowed !important;
}

.prord-send-button .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* ========================================
   Attach Button
   ======================================== */

.prord-attach-button {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    border-radius: 50% !important;
    background: transparent !important;
    color: var(--prord-chat-text-muted) !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 0 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s;
}

.prord-attach-button:hover {
    color: var(--prord-color-accent);
}

.prord-attach-button .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* ========================================
   Attachment Links in Bubbles
   ======================================== */

.prord-chat-attachment-link {
    display: inline-block;
    margin-top: 4px;
    font-size: 13px;
    text-decoration: underline;
    word-break: break-all;
}

.prord-message-own .prord-chat-attachment-link {
    color: rgba(255, 255, 255, 0.9);
}

.prord-message-other .prord-chat-attachment-link {
    color: var(--prord-color-accent);
}

/* ========================================
   File Preview Bar
   ======================================== */

.prord-chat-input-wrapper {
    position: relative;
}

.prord-chat-file-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #eef6f6;
    border-bottom: 1px solid var(--prord-chat-border);
    font-size: 13px;
    color: var(--prord-color-text);
    gap: 8px;
}

.prord-chat-file-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: #999;
    flex-shrink: 0;
}

.prord-chat-file-remove:hover {
    color: var(--prord-chat-error);
}

/* ========================================
   Conversations List
   ======================================== */

.prord-chats-header {
    padding: 24px;
    border-bottom: 1px solid var(--prord-chat-border);
}

.prord-chats-header h1 {
    margin: 0 0 8px 0;
    font-size: 24px;
    color: var(--prord-color-text);
}

.prord-limit-info {
    margin: 0;
    font-size: 13px;
    color: var(--prord-chat-text-muted);
}

.prord-conversations-list {
    display: flex;
    flex-direction: column;
}

.prord-no-conversations {
    padding: 60px 24px;
    text-align: center;
    color: var(--prord-chat-text-light);
}

.prord-no-conversations .dashicons {
    font-size: 64px;
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.prord-no-conversations h3 {
    margin: 0 0 8px 0;
    color: var(--prord-chat-text-muted);
}

.prord-conversation-item {
    display: flex;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.prord-conversation-item:hover {
    background: var(--prord-chat-bg-alt);
}

.prord-conversation-item.prord-has-unread {
    background: rgba(114, 198, 205, 0.1);
}

.prord-conv-avatar {
    position: relative;
    flex-shrink: 0;
}

.prord-conv-avatar img {
    width: 56px;
    height: 56px;
    border-radius: 50% !important;
}

.prord-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--prord-chat-error);
    color: #fff;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
}

.prord-conv-info {
    flex: 1;
    min-width: 0;
}

.prord-conv-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.prord-conv-name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--prord-color-text);
}

.prord-conv-time {
    font-size: 12px;
    color: var(--prord-chat-text-light);
    white-space: nowrap;
}

.prord-last-message {
    margin: 0;
    font-size: 14px;
    color: var(--prord-chat-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.prord-last-message.prord-unread-text {
    font-weight: 600;
    color: var(--prord-color-text);
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {

    .prord-chat-wrapper,
    .prord-chats-wrapper {
        margin: 0;
        padding: 0;
    }

    .prord-chat-container,
    .prord-chats-container {
        border-radius: 0;
        box-shadow: none;
    }

    .prord-chat-messages {
        height: calc(100vh - 200px);
    }

    .prord-message {
        max-width: 85%;
    }

    .prord-conversation-item {
        padding: 12px 16px;
    }
}

/* ========================================
   Chat Button Shortcode
   ======================================== */

.prord-chat-button-wrapper {
    margin: 20px 0;
}

.prord-chat-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--prord-color-accent);
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: background 0.2s;
}

.prord-chat-button:hover {
    background: var(--prord-color-primary);
    color: #fff;
}

.prord-chat-button .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.prord-chat-user-name {
    font-size: 13px;
    opacity: 0.9;
}

/* ========================================
   Chat Icon Shortcode
   ======================================== */

.prord-chat-icon-wrapper {
    display: inline-flex;
    align-items: center;
    position: relative;
}

.prord-chat-icon-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: inherit;
    position: relative;
}

.prord-chat-icon-link:hover {
    color: var(--prord-color-accent);
}

.prord-chat-icon {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.prord-chat-icon-text {
    font-size: 14px;
    font-weight: 500;
}

.prord-chat-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--prord-chat-error);
    color: #fff;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    line-height: 1.4;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Para menús de WordPress */
.menu-item .prord-chat-icon-wrapper {
    vertical-align: middle;
}

.menu-item .prord-chat-icon-link {
    padding: 0;
}