/* Posh Ping Messaging Styles - Mobile First */

/* Import Poppins font */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* Ensure all text uses Poppins font */
.posh-ping-container * {
    font-family: 'Poppins', sans-serif !important;
}

/* Force circular profile pictures */
.conversation-avatar img,
.message-avatar img,
.recipient-avatar img {
    border-radius: 50% !important;
    clip-path: circle(50%);
}

/* Send button icon styling - override all other img rules */
.posh-ping-container .btn-send .send-icon-img {
    width: 24px !important;
    height: 24px !important;
    border-radius: 0 !important;
    clip-path: none !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: 24px !important;
    max-height: 24px !important;
    object-fit: contain !important;
    filter: brightness(0) invert(1) !important; /* Make it white */
}

/* Ping Logo Icon */
.ping-logo-icon {
    height: 16px;
    width: auto;
    margin-right: 6px;
    vertical-align: middle;
    filter: brightness(0) invert(1); /* Makes it white */
    max-width: 16px;
    max-height: 16px;
}

/* Ping Logo Icon Large (50% bigger) */
.ping-logo-icon-large {
    height: 24px;
    width: auto;
    margin-right: 8px;
    vertical-align: middle;
    filter: brightness(0) invert(1); /* Makes it white */
    max-width: 24px;
    max-height: 24px;
}

/* Back Button Text */
.back-text {
    margin-left: 4px;
    font-size: 16px;
    font-weight: 500;
    color: #E0457B;
}

/* Settings Icon */
.settings-icon {
    width: 20px;
    height: 20px;
    stroke: white;
    fill: none;
}

/* Mobile-First Container */
.posh-ping-container {
    width: 100%;
    height: 100vh;
    background: #fff;
    display: flex;
    flex-direction: column;
    font-family: 'Poppins', sans-serif;
    overflow: hidden;
}

/* Mobile Header */
.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #E0457B, #FF6B9D);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.mobile-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.mobile-header .header-icon {
    height: 24px;
    width: auto;
    margin-right: 8px;
    vertical-align: middle;
    border-radius: 0;
    clip-path: none;
    max-width: 24px;
    max-height: 24px;
}

/* Mobile Search */
.mobile-search {
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
    flex-shrink: 0;
}

#conversation-search {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    font-size: 16px;
    background: white;
}

#conversation-search:focus {
    outline: none;
    border-color: #E0457B;
    box-shadow: 0 0 0 3px rgba(224, 69, 123, 0.1);
}

/* Mobile Conversation List */
.mobile-conversation-list {
    flex: 1;
    overflow-y: auto;
    background: white;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f3f4;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

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

.conversation-item.active {
    background: #f0f9ff;
    border-left: 4px solid #E0457B;
}

.conversation-avatar {
    margin-right: 12px;
    flex-shrink: 0;
}

.conversation-avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

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

.conversation-name {
    font-weight: 600;
    font-size: 16px;
    color: #1f2937;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-preview {
    font-size: 14px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-left: 12px;
    flex-shrink: 0;
}

.conversation-time {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 4px;
}

.unread-badge {
    background: #E0457B;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* Mobile Conversation View */
.conversation-view {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: white;
}

.mobile-conversation-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #E0457B, #FF6B9D);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.back-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.back-icon {
    font-size: 18px;
    font-weight: bold;
}

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

.conversation-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-subtitle {
    font-size: 14px;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Message Thread */
.message-thread {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: #f8f9fa;
    min-height: 0;
}

.message {
    display: flex;
    margin-bottom: 16px;
    align-items: flex-end;
}

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

.message-avatar {
    margin: 0 8px;
    flex-shrink: 0;
}

.message-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.message-content {
    position: relative;
    max-width: 70%;
}

.message-bubble {
    background: white;
    border-radius: 18px;
    padding: 12px 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
}

.message.sent .message-bubble {
    background: #E0457B;
    color: white;
}

.message-text {
    font-size: 16px;
    line-height: 1.4;
    word-wrap: break-word;
    margin-bottom: 4px;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    text-align: right;
}

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

.message-image {
    margin-bottom: 8px;
}

.message-image img {
    max-width: 200px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message-reactions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
    position: absolute;
    top: -40px;
    left: 0;
    background: white;
    border-radius: 20px;
    padding: 6px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.message:hover .message-reactions {
    opacity: 1;
    animation: bounceIn 0.3s ease-out;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.8);
    }
    50% {
        transform: translateY(-2px) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.reaction-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e1e5e9;
    border-radius: 16px;
    padding: 4px 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.reaction-btn:hover {
    background: white;
    transform: scale(1.1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.reaction-btn.active {
    background: #E0457B;
    color: white;
    border-color: #E0457B;
}

/* Message Input */
.message-input {
    padding: 16px 20px;
    border-top: 1px solid #e1e5e9;
    background: white;
    flex-shrink: 0;
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: #f8f9fa;
    border-radius: 24px;
    padding: 8px 16px;
    border: 1px solid #e1e5e9;
}

.input-container:focus-within {
    border-color: #E0457B;
    box-shadow: 0 0 0 3px rgba(224, 69, 123, 0.1);
}

.btn-attachment {
    background: #E0457B;
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-attachment:hover {
    background: #d63d6b;
    transform: scale(1.05);
}

.attachment-icon {
    font-size: 20px;
    font-weight: bold;
    line-height: 1;
}

#message-text {
    flex: 1;
    border: none;
    background: none;
    resize: none;
    font-size: 16px;
    line-height: 1.4;
    padding: 8px 0;
    min-height: 20px;
    max-height: 120px;
}

#message-text:focus {
    outline: none;
}

.btn-send {
    background: #E0457B;
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px;
}

.btn-send:hover:not(:disabled) {
    background: #d63d6b;
    transform: scale(1.05);
}

.btn-send:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
}

/* Buttons */
.btn-primary {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-primary:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 10px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

/* Modal Styles */
.recipient-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 16px 20px;
    border-bottom: 1px solid #e1e5e9;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #E0457B;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
    padding: 4px;
    border-radius: 4px;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #374151;
}

/* Quick Selection */
.quick-selection {
    padding: 16px 20px;
    border-bottom: 1px solid #e1e5e9;
    background: #f8f9fa;
}

.quick-selection h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
}

.preset-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.preset-btn {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #374151;
}

.preset-btn:hover {
    background: #E0457B;
    color: white;
    border-color: #E0457B;
}

.preset-btn.active {
    background: #E0457B;
    color: white;
    border-color: #E0457B;
}

/* Search Section */
.search-section {
    padding: 16px 20px;
    border-bottom: 1px solid #e1e5e9;
}

#recipient-search {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px;
}

#recipient-search:focus {
    outline: none;
    border-color: #E0457B;
    box-shadow: 0 0 0 3px rgba(224, 69, 123, 0.1);
}

/* Selected Summary */
.selected-summary {
    padding: 16px 20px;
    background: #f0f9ff;
    border-bottom: 1px solid #e1e5e9;
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.summary-title {
    font-weight: 600;
    color: #374151;
}

.summary-count {
    background: #E0457B;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
}

.summary-preview {
    font-size: 14px;
    color: #6b7280;
}

.no-selection {
    font-style: italic;
}

/* Recipient Results */
.recipient-results {
    padding: 16px 20px;
    max-height: 300px;
    overflow-y: auto;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Group Name */
.group-name-section {
    padding: 16px 20px;
    border-top: 1px solid #e1e5e9;
}

.group-name-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #374151;
}

#group-name {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px;
}

#group-name:focus {
    outline: none;
    border-color: #E0457B;
    box-shadow: 0 0 0 3px rgba(224, 69, 123, 0.1);
}

/* Modal Actions */
.modal-actions {
    padding: 16px 20px;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    position: sticky;
    bottom: 0;
    background: white;
}

.modal-actions .btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    background: #E0457B;
    border: none;
    color: white;
}

.modal-actions .btn-primary:hover {
    background: #d63d6b;
}

.btn-icon {
    font-size: 18px;
}

/* Loading States */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #6b7280;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f4f6;
    border-top: 3px solid #E0457B;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Message Alerts */
.message-alerts {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    z-index: 2000;
    pointer-events: none;
}

.message-alert {
    background: white;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #E0457B;
    pointer-events: auto;
}

.message-alert.error {
    border-left-color: #ef4444;
}

.message-alert.success {
    border-left-color: #10b981;
}

/* Desktop Enhancements */
@media (min-width: 768px) {
    .posh-ping-container {
        max-width: 1200px;
        margin: 0 auto;
        height: calc(100vh - 40px);
        border-radius: 12px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        margin-top: 20px;
        margin-bottom: 20px;
    }
    
    .modal-content {
        border-radius: 16px;
        width: 90%;
        max-width: 600px;
        max-height: 80vh;
        animation: fadeIn 0.3s ease-out;
    }
    
    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: scale(0.9);
        }
        to {
            opacity: 1;
            transform: scale(1);
        }
    }
    
    .recipient-modal {
        align-items: center;
    }
}

@media (min-width: 1024px) {
    .posh-ping-container {
        display: grid;
        grid-template-columns: 300px 1fr;
        height: calc(100vh - 40px);
    }
    
    .conversation-list-view {
        grid-column: 1;
        border-right: 1px solid #e1e5e9;
    }
    
    .conversation-view {
        grid-column: 2;
    }
    
    .mobile-header {
        border-radius: 12px 0 0 0;
    }
    
    .mobile-conversation-header {
        border-radius: 0 12px 0 0;
    }
}