/* Enhanced Messages Page Styles */

/* Page Container */
.cht-messages-page-enhanced {
    padding: 0;
}

/* Header Section */
.cht-messages-header-enhanced {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}

.cht-header-content h1 {
    margin: 0 0 0.5rem 0;
    font-size: 2rem;
    font-weight: 600;
    color: #1f2937;
}

.cht-header-content p {
    margin: 0;
    color: #6b7280;
    font-size: 1rem;
}

/* Alert Cards */
.cht-messages-alerts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.cht-alert-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    border-radius: 12px;
    border-left: 4px solid;
}

.cht-alert-warning {
    background: #FFF3CD;
    border-left-color: #FFC107;
}

.cht-alert-info {
    background: #D1ECF1;
    border-left-color: #17A2B8;
}

.cht-alert-icon {
    font-size: 2rem;
    line-height: 1;
}

.cht-alert-content {
    flex: 1;
}

.cht-alert-content strong {
    display: block;
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
    color: #1a1a1a;
}

.cht-alert-content p {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
}

.cht-alert-action {
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 6px;
    color: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.cht-alert-action:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: translateX(3px);
}

/* Messages Statistics */
.cht-messages-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.cht-stat-card-new {
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s;
}

.cht-stat-card-new:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.cht-stat-icon-new {
    font-size: 2.5rem;
    line-height: 1;
}

.cht-stat-info-new {
    display: flex;
    flex-direction: column;
}

.cht-stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1F2937;
    line-height: 1;
}

.cht-stat-title {
    font-size: 0.875rem;
    color: #6B7280;
    margin-top: 0.25rem;
}

.cht-stat-subtitle {
    font-size: 0.75rem;
    color: #9CA3AF;
    margin-top: 0.125rem;
}

.cht-text-info {
    color: #0EA5E9 !important;
}

/* Enhanced Empty State */
.cht-empty-state-enhanced {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
}

.cht-empty-icon-large {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: block;
}

.cht-empty-state-enhanced h3 {
    font-size: 1.5rem;
    color: #1F2937;
    margin-bottom: 1rem;
}

.cht-empty-state-enhanced p {
    font-size: 1rem;
    color: #6B7280;
    margin-bottom: 2rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.cht-empty-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.cht-contact-info p {
    font-size: 0.875rem;
    color: #6B7280;
    margin: 0;
}

/* Message Sections */
.cht-messages-organized {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.cht-message-section {
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    overflow: hidden;
}

.cht-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: #F9FAFB;
    border-bottom: 1px solid #E5E7EB;
    cursor: default;
}

.cht-section-collapsible .cht-section-header {
    cursor: pointer;
    transition: background 0.2s;
}

.cht-section-collapsible .cht-section-header:hover {
    background: #F3F4F6;
}

.cht-section-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1F2937;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cht-section-count {
    background: #6366F1;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.cht-section-toggle {
    font-size: 1.25rem;
    color: #6B7280;
    transition: transform 0.2s;
}

.cht-section-expanded .cht-section-toggle {
    transform: rotate(180deg);
}

/* Thread Grid */
.cht-threads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
}

/* Enhanced Thread Cards */
.cht-thread-card-enhanced {
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s;
    position: relative;
}

.cht-thread-card-enhanced:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.cht-thread-unread {
    border-left: 4px solid #0EA5E9;
    box-shadow: 0 0 0 1px #0EA5E9;
}

.cht-thread-urgent {
    border-left: 4px solid #EF4444;
    box-shadow: 0 0 0 1px #EF4444;
}

.cht-thread-resolved {
    opacity: 0.8;
    border-color: #D1D5DB;
}

/* Thread Card Header */
.cht-thread-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: #F9FAFB;
    border-bottom: 1px solid #E5E7EB;
}

.cht-thread-priority {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cht-priority-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.cht-priority-urgent {
    background: #FEE2E2;
    color: #991B1B;
}

.cht-status-badge {
    padding: 0.25rem 0.5rem;
    background: #E5E7EB;
    color: #374151;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.cht-thread-time {
    font-size: 0.75rem;
    color: #6B7280;
}

/* Thread Card Content */
.cht-thread-card-content {
    padding: 1.25rem;
}

.cht-thread-subject {
    margin: 0 0 1rem 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1F2937;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cht-unread-indicator {
    background: #EF4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.cht-thread-category {
    margin-bottom: 1rem;
}

.cht-category-badge {
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Thread Booking Info */
.cht-thread-booking-info {
    background: #F3F4F6;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.cht-booking-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: #1F2937;
}

.cht-booking-icon {
    font-size: 1.125rem;
}

.cht-booking-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cht-booking-detail {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.cht-detail-icon {
    font-size: 1rem;
    width: 16px;
    text-align: center;
}

.cht-detail-text {
    color: #4B5563;
}

/* Thread Card Footer */
.cht-thread-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: #F9FAFB;
    border-top: 1px solid #E5E7EB;
}

.cht-thread-stats {
    font-size: 0.875rem;
    color: #6B7280;
}

.cht-message-count {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.cht-thread-actions .cht-btn {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

/* Button Styles */
.cht-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid;
    cursor: pointer;
    text-align: center;
}

.cht-btn-primary {
    background: #6366F1;
    border-color: #6366F1;
    color: white;
}

.cht-btn-primary:hover {
    background: #4F46E5;
    border-color: #4F46E5;
    transform: translateY(-1px);
}

.cht-btn-outline {
    background: transparent;
    border-color: #D1D5DB;
    color: #6B7280;
}

.cht-btn-outline:hover {
    border-color: #9CA3AF;
    color: #374151;
    background: #F9FAFB;
}

.cht-btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.cht-btn-lg {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .cht-threads-grid {
        grid-template-columns: 1fr;
    }
    
    .cht-messages-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .cht-messages-header-enhanced {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .cht-messages-alerts {
        grid-template-columns: 1fr;
    }
    
    .cht-messages-stats {
        grid-template-columns: 1fr;
    }
    
    .cht-threads-grid {
        padding: 1rem;
        gap: 1rem;
    }
    
    .cht-thread-card-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .cht-thread-card-footer {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
    
    .cht-empty-actions {
        flex-direction: column;
    }
    
    .cht-section-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
}

/* Loading states */
.cht-messages-loading {
    text-align: center;
    padding: 2rem;
    color: #6B7280;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cht-thread-card-enhanced {
    animation: slideIn 0.3s ease-out;
}

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

.cht-unread-indicator {
    animation: pulse 2s infinite;
}

/* Special thread type styling */
.cht-thread-urgent .cht-thread-card-header {
    background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);
}

.cht-thread-booking .cht-category-badge {
    background: #3B82F6;
}

.cht-thread-general .cht-category-badge {
    background: #6B7280;
}

.cht-thread-resolved .cht-thread-card-header {
    background: #F0F9F0;
}

.cht-thread-resolved .cht-thread-subject {
    color: #6B7280;
}

/* Section transitions */
.cht-section-content {
    transition: all 0.3s ease-in-out;
    overflow: hidden;
}

.cht-section-collapsible.cht-section-expanded {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Simple Timeline Styles */
.cht-threads-timeline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem;
}

.cht-thread-card-simple {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    transition: all 0.3s;
    position: relative;
}

.cht-thread-card-simple:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.cht-thread-card-simple.cht-thread-unread {
    border-left: 4px solid #0EA5E9;
    box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.1);
}

/* Timeline Marker */
.cht-thread-timeline-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
}

.cht-timeline-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #F3F4F6;
    border: 2px solid #E5E7EB;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.cht-timeline-dot.cht-dot-unread {
    background: #EFF6FF;
    border-color: #0EA5E9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.cht-timeline-date {
    font-size: 0.75rem;
    color: #6B7280;
    text-align: center;
    font-weight: 500;
}

/* Thread Content */
.cht-thread-content-simple {
    flex: 1;
    min-width: 0;
}

.cht-thread-header-simple {
    margin-bottom: 1rem;
}

.cht-thread-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
}

.cht-thread-title a {
    color: #1F2937;
    text-decoration: none;
    transition: color 0.2s;
}

.cht-thread-title a:hover {
    color: #0EA5E9;
}

.cht-unread-badge {
    background: #EF4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 10px;
    margin-left: 0.5rem;
    animation: pulse 2s infinite;
}

.cht-thread-meta-simple {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #6B7280;
}

/* Booking Context */
.cht-booking-context {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.cht-booking-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: #1F2937;
}

.cht-booking-icon {
    font-size: 1rem;
}

.cht-booking-ref {
    background: #E0E7FF;
    color: #3730A3;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.cht-package-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #4B5563;
}

.cht-package-title {
    font-weight: 600;
    color: #1F2937;
}

.cht-tour-date, .cht-travelers {
    color: #6B7280;
}

/* Thread Preview - Enhanced Styling */
.cht-thread-preview {
    margin: 15px 0;
    padding: 12px 16px;
    background: #f1f5f9;
    border-radius: 6px;
    border-left: 3px solid #94a3b8;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.cht-thread-preview p {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: #475569;
    font-weight: 500;
}

/* Special styling for unread message previews */
.cht-thread-unread .cht-thread-preview {
    background: #dbeafe;
    border-left-color: #3b82f6;
}

.cht-thread-unread .cht-thread-preview p {
    color: #1e40af;
    font-weight: 600;
}

/* Thread Actions */
.cht-thread-actions-simple {
    display: flex;
    gap: 0.75rem;
}

.cht-section-subtitle {
    font-size: 0.875rem;
    color: #6B7280;
    font-weight: normal;
    margin-left: auto;
}

/* Simple Unread Alert */
.cht-unread-alert {
    background: #EFF6FF;
    border: 1px solid #93C5FD;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 2rem;
}

.cht-unread-alert .cht-alert-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #1E40AF;
    font-weight: 500;
}

.cht-alert-icon {
    font-size: 1.25rem;
}

/* Conversation View Styles */
.cht-conversation-view {
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

.cht-conversation-header {
    background: #F8FAFC;
    border-bottom: 1px solid #E2E8F0;
    padding: 2rem;
}

.cht-header-nav {
    margin-bottom: 1rem;
}

.cht-back-btn {
    color: #6B7280;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.cht-back-btn:hover {
    color: #374151;
}

.cht-conversation-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1F2937;
    margin: 0 0 1rem 0;
    line-height: 1.3;
}

.cht-conversation-context {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.cht-context-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cht-context-label {
    font-weight: 600;
    color: #6B7280;
    min-width: 80px;
}

.cht-context-value {
    color: #1F2937;
}

.cht-context-link {
    color: #0EA5E9;
    text-decoration: none;
    font-weight: 500;
}

.cht-context-link:hover {
    text-decoration: underline;
}

/* Messages Area */
.cht-conversation-messages {
    padding: 2rem;
    max-height: 600px;
    overflow-y: auto;
}

.cht-message-item {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #F3F4F6;
}

.cht-message-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.cht-message-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.cht-message-sender {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cht-sender-icon {
    font-size: 1.125rem;
}

.cht-sender-name {
    font-weight: 600;
    color: #1F2937;
}

.cht-message-customer .cht-sender-name {
    color: #0EA5E9;
}

.cht-auto-badge {
    background: #F3F4F6;
    color: #6B7280;
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.cht-message-time {
    color: #6B7280;
    font-size: 0.875rem;
}

.cht-message-content {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 1.25rem;
    line-height: 1.6;
    color: #374151;
}

.cht-message-customer .cht-message-content {
    background: #EFF6FF;
    border-color: #BFDBFE;
}

.cht-message-attachments {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.cht-attachment-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
    background: #F3F4F6;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    color: #374151;
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.cht-attachment-link:hover {
    background: #E5E7EB;
    transform: translateY(-1px);
}

/* Reply Section */
.cht-conversation-reply {
    background: #F8FAFC;
    border-top: 1px solid #E2E8F0;
    padding: 2rem;
}

.cht-reply-header h3 {
    margin: 0 0 1rem 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1F2937;
}

.cht-reply-input {
    margin-bottom: 1rem;
}

.cht-reply-input textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s;
}

.cht-reply-input textarea:focus {
    outline: none;
    border-color: #0EA5E9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.cht-reply-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cht-attach-section input[type="file"] {
    display: none;
}

.cht-attach-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #F3F4F6;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    color: #374151;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.cht-attach-btn:hover {
    background: #E5E7EB;
}

/* Responsive Timeline */
@media (max-width: 768px) {
    .cht-thread-card-simple {
        flex-direction: column;
        gap: 1rem;
    }
    
    .cht-thread-timeline-marker {
        flex-direction: row;
        min-width: auto;
        align-items: center;
        gap: 0.75rem;
    }
    
    .cht-timeline-dot {
        margin-bottom: 0;
    }
    
    .cht-threads-timeline {
        padding: 1rem;
        gap: 1rem;
    }
    
    .cht-package-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .cht-thread-meta-simple {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .cht-conversation-header,
    .cht-conversation-messages,
    .cht-conversation-reply {
        padding: 1rem;
    }
    
    .cht-conversation-context {
        grid-template-columns: 1fr;
    }
    
    .cht-message-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .cht-reply-actions {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
}
