/* ═══════════════════════════════════════════════
   Portal Doméstico — Chat Styles
   ═══════════════════════════════════════════════ */

.pd-chat-wrapper {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 600px;
    background: var(--pd-white);
    border-radius: var(--pd-radius);
    box-shadow: var(--pd-shadow-md);
    border: 1px solid var(--pd-border);
    overflow: hidden;
}

/* ─── Sidebar ─── */
.pd-chat-sidebar {
    border-right: 1px solid var(--pd-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pd-chat-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--pd-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.pd-chat-sidebar-header h3 {
    margin: 0;
    font-size: 16px;
}

.pd-chat-list {
    flex: 1;
    overflow-y: auto;
}

.pd-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--pd-text);
    border-bottom: 1px solid var(--pd-border);
    transition: background 0.15s;
    cursor: pointer;
}

.pd-chat-item:hover {
    background: var(--pd-bg);
}

.pd-chat-item-active {
    background: var(--pd-primary-light);
}

.pd-chat-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.pd-chat-item-info {
    flex: 1;
    min-width: 0;
}

.pd-chat-item-info strong {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.pd-chat-item-preview {
    display: block;
    font-size: 12px;
    color: var(--pd-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pd-unread-badge {
    background: var(--pd-danger);
    color: white;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.pd-chat-empty-list {
    text-align: center;
    padding: 40px 20px;
    color: var(--pd-text-muted);
    font-size: 14px;
}

/* ─── Main chat area ─── */
.pd-chat-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pd-chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--pd-border);
    background: var(--pd-bg);
    flex-wrap: nowrap;
    min-height: 56px;
}

.pd-chat-back {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}

.pd-chat-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.pd-chat-header-info strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pd-chat-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.pd-chat-header-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* ─── Messages ─── */
.pd-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--pd-bg);
}

.pd-message {
    display: flex;
    gap: 8px;
    max-width: 75%;
}

.pd-message-mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.pd-message-other {
    align-self: flex-start;
}

.pd-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    align-self: flex-end;
}

.pd-message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.pd-message-mine .pd-message-bubble {
    background: var(--pd-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.pd-message-other .pd-message-bubble {
    background: var(--pd-white);
    border: 1px solid var(--pd-border);
    border-bottom-left-radius: 4px;
}

.pd-message-time {
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.7;
}

.pd-message-mine .pd-message-time {
    text-align: right;
}

/* ─── Input wrapper ─── */
.pd-chat-input-wrapper {
    border-top: 1px solid var(--pd-border);
    background: var(--pd-white);
}

/* ─── Input area ─── */
.pd-chat-input-area {
    display: flex;
    gap: 6px;
    padding: 10px 12px 4px;
    align-items: flex-end;
}

.pd-chat-input-area textarea {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--pd-border);
    border-radius: 20px;
    font-family: var(--pd-font);
    font-size: 14px;
    resize: none;
    min-height: 20px;
    max-height: 100px;
}

.pd-chat-input-area .pd-btn {
    align-self: flex-end;
    border-radius: 20px;
}

/* ─── Extra actions below input ─── */
.pd-chat-input-extra {
    padding: 4px 12px 10px;
}

#pd-share-location {
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

/* ─── Empty chat ─── */
.pd-chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pd-text-muted);
    text-align: center;
    padding: 40px;
}

/* ─── Maps link in messages ─── */
.pd-maps-link {
    display: inline-block;
    padding: 6px 12px;
    background: #059669;
    color: white !important;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    margin-top: 4px;
}

.pd-maps-link:hover {
    background: #047857;
}

.pd-message-mine .pd-maps-link {
    background: rgba(255,255,255,0.2);
}

.pd-message-mine .pd-maps-link:hover {
    background: rgba(255,255,255,0.3);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .pd-chat-wrapper {
        grid-template-columns: 1fr;
        height: calc(100vh - 100px);
    }

    .pd-chat-sidebar {
        display: none;
    }

    .pd-chat-wrapper.pd-show-sidebar .pd-chat-sidebar {
        display: flex;
    }

    .pd-chat-wrapper.pd-show-sidebar .pd-chat-main {
        display: none;
    }

    .pd-chat-back {
        display: block;
    }

    .pd-chat-header {
        padding: 8px 10px;
        gap: 4px;
        flex-wrap: wrap;
    }

    .pd-chat-header-info {
        flex: 1;
        min-width: 0;
    }

    .pd-chat-header-avatar {
        width: 28px;
        height: 28px;
    }

    .pd-chat-header-info strong {
        font-size: 13px;
    }

    .pd-chat-header-actions {
        width: 100%;
        gap: 6px;
    }

    .pd-chat-header-actions .pd-btn {
        padding: 3px 6px;
        font-size: 11px;
    }

    .pd-message {
        max-width: 90%;
    }

    .pd-chat-input-area {
        padding: 8px 8px 2px;
        gap: 4px;
    }

    .pd-chat-input-extra {
        padding: 2px 8px 8px;
    }

    #pd-share-location {
        padding: 5px 8px;
        font-size: 11px;
    }
}
