/* ========================================
   CHAT COMPONENT STYLES
   Dr. Servicios - Sistema de Mensajería
   ======================================== */

/* Chat Modal Overlay */
.chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000; /* Higher than Chequéa (9999) to display on top */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 1rem;
}

.chat-modal.show {
    opacity: 1;
    pointer-events: all;
}

/* Chat Container */
.chat-container {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    height: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.chat-modal.show .chat-container {
    transform: scale(1) translateY(0);
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Online status indicator removed */

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

.chat-user-name {
    font-weight: 600;
    font-size: 1rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Business name for providers (green text) */
.chat-business-name {
    font-size: 0.8rem;
    color: #10b981;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: none; /* Hidden by default, shown via JS when provider */
}

/* Online status text removed */

.chat-close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Phone Button */
.chat-phone-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
    flex-shrink: 0;
    text-decoration: none;
}

.chat-phone-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.chat-phone-btn svg {
    width: 20px;
    height: 20px;
}

/* Chat Back Button */
.chat-back-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-back-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(-2px);
}

.chat-back-btn svg {
    width: 24px;
    height: 24px;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Message Bubble */
.message {
    display: flex;
    gap: 0.5rem;
    max-width: 80%;
    animation: messageSlideIn 0.3s ease;
}

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

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

.message.received {
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    color: white;
    text-transform: uppercase;
    flex-shrink: 0;
    overflow: hidden;
}

.message-avatar.clickable-avatar {
    cursor: pointer;
    transition: all 0.2s ease;
}

.message-avatar.clickable-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.sent .message-bubble {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.7rem;
    color: #9ca3af;
    padding: 0 0.5rem;
}

.message.sent .message-time {
    text-align: right;
}

.message.received .message-time {
    text-align: left;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: #6b7280;
    font-size: 0.875rem;
    font-style: italic;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.typing-indicator.show {
    opacity: 1;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typingAnimation 1.4s infinite;
}

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

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

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

/* Empty State */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    text-align: center;
    padding: 2rem;
}

.chat-empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.chat-empty-state p {
    margin: 0;
    font-size: 0.95rem;
}

/* Chat Input Area */
.chat-input-container {
    padding: 1rem;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.chat-input-wrapper {
    flex: 1;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: #3b82f6;
    background: white;
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    resize: none;
    outline: none;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.5;
}

.chat-input::placeholder {
    color: #9ca3af;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
    flex-shrink: 0;
    opacity: 0.5;
    pointer-events: none;
}

.chat-send-btn.active {
    opacity: 1;
    pointer-events: auto;
}

.chat-send-btn.active:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.chat-send-btn.active:active {
    transform: scale(0.95);
}

/* Chat Attachment Buttons */
.chat-attachment-buttons {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.chat-attach-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-attach-btn:hover {
    background: #e5e7eb;
    color: #3b82f6;
}

.chat-attach-btn:active {
    transform: scale(0.95);
}

/* Media Preview Area */
.chat-media-preview {
    padding: 12px 16px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.media-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.media-preview-header span {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

.media-preview-clear {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
}

.media-preview-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.media-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
    background: #e5e7eb;
}

.media-preview-item img,
.media-preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-preview-item .media-remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-preview-item .media-type-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

/* Location Preview Area */
.chat-location-preview {
    padding: 12px 16px;
    background: #f0fdf4;
    border-top: 1px solid #bbf7d0;
}

.location-preview-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #bbf7d0;
}

.location-preview-icon {
    font-size: 24px;
}

.location-preview-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.location-preview-name {
    font-size: 14px;
    font-weight: 600;
    color: #166534;
}

.location-preview-coords {
    font-size: 12px;
    color: #6b7280;
}

.location-preview-close {
    width: 28px;
    height: 28px;
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    color: #6b7280;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.location-preview-close:hover {
    background: #e5e7eb;
    color: #ef4444;
}

/* Message with Location */
.message-location {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f0fdf4;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
}

.message-location:hover {
    background: #dcfce7;
}

.message-location-icon {
    font-size: 20px;
}

.message-location-info {
    flex: 1;
}

.message-location-name {
    font-size: 13px;
    font-weight: 600;
    color: #166534;
}

.message-location-action {
    font-size: 11px;
    color: #16a34a;
}

/* Message with Media */
.message-media {
    margin-top: 8px;
    border-radius: 12px;
    overflow: hidden;
    max-width: 250px;
}

.message-media img {
    width: 100%;
    display: block;
    cursor: pointer;
}

.message-media video {
    width: 100%;
    display: block;
    border-radius: 12px;
}

/* Conversations List */
.conversations-list {
    background: white;
    border-radius: 16px;
    overflow: hidden;
}

.conversations-header {
    padding: 1.25rem;
    background: white;
    border-bottom: 1px solid #e5e7eb;
}

.conversations-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
}

.conversations-items {
    max-height: 500px;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid #f3f4f6;
    position: relative;
}

.conversation-item:hover {
    background: #f9fafb;
}

.conversation-item:active {
    background: #f3f4f6;
}

.conversation-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    text-transform: uppercase;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.conversation-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Online status indicator removed */

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1f2937;
    margin: 0 0 0.25rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Business name for providers in conversation list (green text) */
.conversation-business-name {
    font-size: 0.8rem;
    color: #10b981;
    font-weight: 500;
    margin: 0 0 0.25rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.conversation-last-message {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.conversation-time {
    font-size: 0.75rem;
    color: #9ca3af;
}

.conversation-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #ef4444;
    color: white;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   UNREAD CONVERSATIONS STYLES
   Visual distinction for unread messages
   ======================================== */

/* Unread conversation item - subtle blue background */
.conversation-item.has-unread {
    background: #eff6ff; /* Light blue background */
}

.conversation-item.has-unread:hover {
    background: #dbeafe; /* Slightly darker on hover */
}

/* Bold name for unread conversations */
.conversation-item.has-unread .conversation-name {
    font-weight: 700;
    color: #1e40af; /* Darker blue for emphasis */
}

/* Bold last message for unread conversations */
.conversation-item.has-unread .conversation-last-message {
    font-weight: 600;
    color: #1f2937; /* Darker text for readability */
}

/* New Message Indicator */
.conversation-unread-dot {
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
}

@keyframes pulse-dot {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0);
    }
}

/* New Message Highlight Animation */
.conversation-item.new-message-highlight {
    animation: highlight-fade 2s ease-out;
    background: #dbeafe;
}

@keyframes highlight-fade {
    0% {
        background: #dbeafe;
    }
    100% {
        background: transparent;
    }
}

/* Empty Conversations */
.conversations-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: #9ca3af;
}

.conversations-empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.conversations-empty p {
    margin: 0;
    font-size: 0.95rem;
}

/* Loading State */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.chat-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ========================================
   UNREAD MESSAGE BADGE
   ======================================== */

.unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    animation: badge-appear 0.3s ease;
    z-index: 10;
}

@keyframes badge-appear {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Scrollbar Styles */
.chat-messages::-webkit-scrollbar,
.conversations-items::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.conversations-items::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb,
.conversations-items::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.conversations-items::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Chat Views (Conversations & Chat) */
.conversations-view,
.chat-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.conversations-view {
    opacity: 1;
    transform: translateX(0);
}

.conversations-view.hide {
    opacity: 0;
    transform: translateX(-20px);
}

.chat-view {
    opacity: 0;
    transform: translateX(20px);
}

.chat-view.show {
    opacity: 1;
    transform: translateX(0);
}

/* Disable all transitions */
.no-transition {
    transition: none !important;
}

/* Ensure conversations items take full height */
.conversations-view {
    display: flex;
    flex-direction: column;
}

.conversations-items {
    flex: 1;
    overflow-y: auto;
}

/* ========================================
   ✅ NEW: LINK PREVIEW CARDS
   ======================================== */

/* Clickeable links in messages */
.message-link {
    color: #4ADE80;
    text-decoration: underline;
    word-break: break-all;
    transition: color 0.2s;
}

.message-link:hover {
    color: #22c55e;
}

/* Message text (before preview card) */
.message-text {
    margin-bottom: 12px;
    line-height: 1.5;
}

/* Pulguero Preview Card */
.pulguero-preview-card {
    margin-top: 8px;
    border-radius: 12px;
    overflow: hidden;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    max-width: 320px;
    transition: all 0.2s;
}

.pulguero-preview-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

/* Preview Link */
.preview-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* Preview Loading State */
.preview-loading {
    padding: 24px;
    text-align: center;
    color: #9ca3af;
}

.preview-spinner {
    width: 32px;
    height: 32px;
    margin: 0 auto 12px;
    border: 3px solid #e5e7eb;
    border-top-color: #4ADE80;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Preview Image */
.preview-image {
    width: 100%;
    height: 140px;
    background-size: cover;
    background-position: center;
    background-color: #f3f4f6;
    position: relative;
}

.preview-no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
}

.preview-icon {
    font-size: 48px;
}

/* Status Badge */
.preview-status-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.preview-status-badge.sold {
    background: rgba(239, 68, 68, 0.95);
    color: white;
}

/* Preview Content */
.preview-content {
    padding: 12px;
}

/* When there's no image, make content more prominent */
.preview-content-no-image {
    padding: 20px 16px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.preview-title {
    margin: 0 0 6px 0;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Bigger title when no image */
.preview-content-no-image .preview-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 10px;
}

.preview-price {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 700;
    color: #4ADE80;
}

/* Bigger price when no image */
.preview-content-no-image .preview-price {
    font-size: 24px;
    margin-bottom: 8px;
}

.preview-location {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
}

.preview-description {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
}

/* Preview Footer */
.preview-footer {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.preview-cta {
    font-size: 14px;
    font-weight: 600;
    color: #4ADE80;
}

/* Preview Error State */
.preview-error {
    padding: 24px;
    text-align: center;
    color: #6b7280;
}

.preview-error .preview-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

/* Responsive */
@media (max-width: 640px) {
    .chat-modal {
        padding: 0;
    }

    .chat-container {
        max-width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .message {
        max-width: 85%;
    }

    /* Adjust preview card for mobile */
    .pulguero-preview-card {
        max-width: 100%;
    }

    .preview-image {
        height: 120px;
    }

    .preview-content {
        padding: 10px;
    }

    .preview-content-no-image {
        padding: 16px 12px;
        min-height: 100px;
    }

    .preview-title {
        font-size: 14px;
    }

    .preview-content-no-image .preview-title {
        font-size: 16px;
    }

    .preview-price {
        font-size: 16px;
    }

    .preview-content-no-image .preview-price {
        font-size: 20px;
    }
}

/* ========================================
   FLOATING PREVIEW (WhatsApp-style)
   Preview shown BEFORE sending message
   ======================================== */

.chat-floating-preview {
    padding: 12px 16px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    animation: slideUp 0.2s ease-out;
}

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

.floating-preview-content {
    position: relative;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    max-width: 320px;
}

.floating-preview-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.floating-preview-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.floating-preview-close:active {
    transform: scale(0.95);
}

/* Reuse existing preview card styles */
.floating-preview-content .preview-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.floating-preview-content .preview-image {
    width: 100%;
    height: 140px;
    background-size: cover;
    background-position: center;
    background-color: #f3f4f6;
    position: relative;
}

.floating-preview-content .preview-content {
    padding: 12px;
}

.floating-preview-content .preview-content-no-image {
    padding: 20px 16px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.floating-preview-content .preview-title {
    margin: 0 0 6px 0;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.floating-preview-content .preview-price {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 700;
    color: #4ADE80;
}

.floating-preview-content .preview-location {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
}

/* Mobile styles for floating preview */
@media (max-width: 768px) {
    .chat-floating-preview {
        padding: 10px 12px;
    }

    .floating-preview-content {
        max-width: 100%;
    }

    .floating-preview-content .preview-image {
        height: 120px;
    }

    .floating-preview-content .preview-content {
        padding: 10px;
    }

    .floating-preview-close {
        width: 24px;
        height: 24px;
        font-size: 18px;
    }
}

/* ========================================
   MEDIA & LOCATION ATTACHMENT STYLES
   ======================================== */

/* Media Preview Remove Button */
.media-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.2s;
}

.media-preview-remove:hover {
    background: rgba(239, 68, 68, 0.9);
}

/* Video Icon in Preview */
.media-preview-video-icon {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

/* Location Coordinates */
.message-location-coords {
    display: block;
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

.message-location-title {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #166534;
}

.message-location-action {
    display: block;
    font-size: 11px;
    color: #16a34a;
    margin-top: 4px;
}

/* Message Media Grid Layouts */
.message-media-single {
    max-width: 280px;
}

.message-media-single .message-media-item {
    width: 100%;
}

.message-media-double {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    max-width: 280px;
}

.message-media-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    max-width: 280px;
}

.message-media-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #e5e7eb;
}

.message-media-item.image img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: opacity 0.2s;
}

.message-media-item.image img:hover {
    opacity: 0.9;
}

.message-media-item.video video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

/* Message Text with Media */
.message-bubble .message-text {
    margin-bottom: 8px;
    word-wrap: break-word;
}

/* Fullscreen Media Overlay */
.media-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.media-fullscreen-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.media-fullscreen-content img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
}

.media-fullscreen-content video {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
}

.media-fullscreen-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.media-fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Loading State for Attachment Buttons */
.chat-attach-btn.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.chat-attach-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top-color: #4ADE80;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Location Preview Coordinates */
.location-preview-coords {
    font-size: 11px;
    color: #6b7280;
    display: block;
}

.location-preview-name {
    font-size: 14px;
    font-weight: 600;
    color: #166534;
    display: block;
}

/* Mobile Responsive for Media */
@media (max-width: 768px) {
    .message-media-single,
    .message-media-double,
    .message-media-grid {
        max-width: 220px;
    }

    .media-fullscreen-content {
        max-width: 95vw;
        max-height: 85vh;
    }

    .media-fullscreen-close {
        top: -50px;
        right: 10px;
    }
}

/* ========================================
   LOCATION PICKER MODAL
   ======================================== */

.location-picker-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.location-picker-container {
    background: white;
    border-radius: 14px;
    width: 280px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
    animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.location-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #166534;
    color: white;
}

.location-picker-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.location-picker-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.location-picker-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.location-picker-confirm {
    background: white;
    color: #166534;
    border: none;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.location-picker-confirm:hover {
    background: #f0fdf4;
    transform: scale(1.02);
}

.location-picker-confirm:active {
    transform: scale(0.98);
}

.location-picker-map {
    position: relative;
    background: #e5e7eb;
    height: 220px;
    min-height: 220px;
}

.location-picker-map #leaflet-map {
    width: 100%;
    height: 100%;
}

/* Locate Me Button */
.location-picker-locate-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 1000;
    background: white;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: all 0.2s;
}

.location-picker-locate-btn:hover {
    background: #f0fdf4;
    transform: scale(1.08);
}

.location-picker-locate-btn:active {
    transform: scale(0.92);
}

.location-picker-locate-btn svg {
    width: 18px;
    height: 18px;
    fill: #166534;
}

.location-picker-locate-btn.locating {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.location-picker-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    gap: 12px;
    z-index: 1000;
}

.location-picker-loading p {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
}

.location-picker-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f0fdf4;
    border-top: 1px solid #dcfce7;
}

.location-picker-icon {
    font-size: 18px;
}

.location-picker-coords {
    font-size: 11px;
    color: #166534;
    flex: 1;
    line-height: 1.4;
}

/* Custom Leaflet marker */
.custom-marker-icon {
    background: none;
    border: none;
}

.marker-pin {
    width: 40px;
    height: 40px;
    position: relative;
}

.marker-pin::before {
    content: '📍';
    font-size: 36px;
    position: absolute;
    top: -36px;
    left: 50%;
    transform: translateX(-50%);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Leaflet controls override */
.location-picker-map .leaflet-control-zoom {
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.location-picker-map .leaflet-control-zoom a {
    background: white;
    color: #166534;
    border: none;
    width: 36px;
    height: 36px;
    line-height: 36px;
    font-size: 18px;
}

.location-picker-map .leaflet-control-zoom a:hover {
    background: #f0fdf4;
}

/* Mobile Responsive - Keep compact square on all screens */
@media (max-width: 480px) {
    .location-picker-modal {
        padding: 16px;
    }

    .location-picker-container {
        width: 280px;
        max-width: 90vw;
        border-radius: 14px;
        /* NO height: 100vh - keep compact */
    }
}
