/* Email Chain Interface Styles */

.ilei-email-chain-interface {
    max-width: 1200px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ilei-email-header {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ilei-email-header h2 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 24px;
    font-weight: 600;
}

.ilei-user-info {
    display: flex;
    gap: 20px;
    color: #6c757d;
    font-size: 14px;
}

.ilei-user-email {
    font-weight: 500;
    color: #495057;
}

.ilei-email-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    min-height: 600px;
}

/* Email Chains List */
.ilei-email-chains-list {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    overflow: visible; /* Change from hidden to visible */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ilei-email-chains-list h3 {
    margin: 0;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
}

.ilei-chains-list {
    max-height: none; /* Remove height restriction */
    overflow-y: visible; /* Remove scroll restriction */
    display: block !important; /* Ensure visibility */
}

#ilei-chains-container {
    display: block !important;
    min-height: 100px;
    position: relative;
}

.ilei-chain-item {
    padding: 15px 20px;
    border-bottom: 1px solid #f1f3f4;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: block !important; /* Ensure visibility */
    margin-bottom: 5px; /* Add spacing between items */
    position: relative; /* Ensure proper positioning */
    z-index: 1; /* Ensure items are above other elements */
}

.ilei-chain-item:hover {
    background-color: #f8f9fa;
}

.ilei-chain-item.active {
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
}

.ilei-chain-item .ilei-chain-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.ilei-chain-item .ilei-chain-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.3;
}

.ilei-chain-item .ilei-chain-date {
    margin: 0;
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
    margin-left: 10px;
}

.ilei-chain-item .ilei-chain-preview {
    font-size: 13px;
    color: #495057;
    line-height: 1.4;
}

.ilei-chain-item .ilei-chain-sender {
    font-weight: 600;
    color: #2c3e50;
}

.ilei-chain-item .ilei-chain-message {
    color: #6c757d;
}

.ilei-chain-item .ilei-chain-opportunity {
    font-weight: 600;
    color: #2c3e50;
    font-size: 12px;
    display: block;
    margin-bottom: 4px;
}

/* Reply items in chains list */
.ilei-chain-replies {
    margin-top: 10px;
    padding-left: 20px;
    border-left: 2px solid #e9ecef;
}

.ilei-chain-reply {
    padding: 8px 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-radius: 4px;
    margin-bottom: 5px;
}

.ilei-chain-reply:hover {
    background-color: #f8f9fa;
}

.ilei-chain-reply-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.ilei-chain-reply-header h5 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #495057;
}

.ilei-chain-reply-date {
    font-size: 11px;
    color: #6c757d;
}

.ilei-chain-reply-preview {
    font-size: 12px;
    color: #6c757d;
    line-height: 1.3;
}

.ilei-chain-reply-message {
    color: #6c757d;
}

/* Email Chain View */
.ilei-email-chain-view {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ilei-select-chain {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    font-size: 16px;
}

.ilei-chain-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ilei-chain-view-header {
    padding: 20px;
    border-bottom: 1px solid #e1e5e9;
    background: #f8f9fa;
}

.ilei-chain-view-header h3 {
    margin: 0 0 5px 0;
    color: #2c3e50;
    font-size: 20px;
    font-weight: 600;
}

.ilei-chain-subtitle {
    margin: 0;
    color: #6c757d;
    font-size: 14px;
}

/* Messages Container */
.ilei-messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: 500px;
    background-color: #f8f9fa;
    border-radius: 8px;
    margin: 0 20px;
}

/* Separators */
.ilei-initial-separator,
.ilei-conversation-separator {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.ilei-initial-separator::before,
.ilei-conversation-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: #e1e5e9;
    z-index: 1;
}

.ilei-initial-separator span,
.ilei-conversation-separator span {
    background-color: #f8f9fa;
    padding: 0 15px;
    color: #6c757d;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 2;
}

/* Initial Email Styling */
.ilei-message-initial {
    margin-bottom: 30px;
    max-width: 100%;
}

.ilei-message-initial .ilei-message-content {
    background: #ffffff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ilei-message-initial .ilei-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f3f4;
}

.ilei-message-initial .ilei-message-sender {
    font-weight: 600;
    color: #2c3e50;
}

.ilei-message-initial .ilei-message-date {
    font-size: 12px;
    color: #6c757d;
}

.ilei-message-initial .ilei-message-body {
    line-height: 1.6;
    color: #333;
}

/* Chat-like Message Styling */
.ilei-message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-end;
}

.ilei-message-incoming {
    justify-content: flex-start;
}

.ilei-message-outgoing {
    justify-content: flex-end;
}

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

.ilei-message-incoming .ilei-message-bubble {
    margin-right: auto;
}

.ilei-message-outgoing .ilei-message-bubble {
    margin-left: auto;
}

.ilei-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

.ilei-message-incoming .ilei-message-content {
    background: #ffffff;
    color: #2c3e50;
    border: 1px solid #e1e5e9;
    border-bottom-left-radius: 4px;
}

.ilei-message-outgoing .ilei-message-content {
    background: #2196f3;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.ilei-message-body {
    margin-bottom: 5px;
}

.ilei-message-meta {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    font-size: 11px;
    opacity: 0.8;
}

.ilei-message-time {
    font-style: italic;
}

.ilei-message-status {
    font-weight: 500;
    margin-right: 20px;
}

/* Reply Form Styling */
.ilei-reply-form {
    padding: 20px;
    border-top: 1px solid #e1e5e9;
    background: #ffffff;
    border-radius: 0 0 8px 8px;
}

.ilei-reply-input-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 20px;
    padding: 10px 15px;
}

#ilei-reply-message {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    max-height: 100px;
    min-height: 20px;
}

.ilei-send-reply {
    background: #2196f3;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.ilei-send-reply:hover {
    background: #1976d2;
}

.ilei-send-reply:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.ilei-send-icon {
    font-size: 16px;
    font-weight: bold;
}

/* Loading and Error States */
.ilei-loading {
    text-align: center;
    color: #6c757d;
    padding: 40px 20px;
}

.ilei-error {
    text-align: center;
    color: #dc3545;
    padding: 20px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    margin: 20px;
}

.ilei-no-chains {
    text-align: center;
    color: #6c757d;
    padding: 40px 20px;
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ilei-messages-container {
        margin: 0 10px;
        padding: 15px;
    }
    
    .ilei-message-bubble {
        max-width: 85%;
    }
    
    .ilei-reply-input-container {
        padding: 8px 12px;
    }
}

/* Login Required */
.ilei-login-required {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-size: 16px;
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
}

/* Admin Page Styling */
.wrap .ilei-email-chain-interface {
    margin-top: 20px;
}

.wrap .ilei-email-header {
    margin-bottom: 20px;
}

/* Override email template styles in admin context */
.wrap .ilei-email-chain-interface body {
    font-family: inherit !important;
    line-height: inherit !important;
    color: inherit !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: transparent !important;
}

.wrap .ilei-email-chain-interface * {
    max-width: none !important;
}

/* Ensure email content is properly contained */
.wrap .ilei-message-content {
    margin: 0 auto !important;
    font-family: Arial, sans-serif !important;
    line-height: 1.6 !important;
    color: #333 !important;
    background-color: #f4f4f4 !important;
    padding: 20px !important;
}

/* Override any global body styles that might leak */
.wrap .ilei-email-chain-interface .email-template {
    margin: 0 auto;
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
    padding: 20px;
}

/* Override any email template body styles that might leak */
.wrap .ilei-email-chain-interface .email-template body {
    max-width: none !important;
    font-family: inherit !important;
    line-height: inherit !important;
    color: inherit !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: transparent !important;
} 

/* Accordion-style message interface */
.ilei-message-accordion {
    margin-bottom: 10px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.ilei-message-header-toggle {
    background: #f8f9fa;
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s ease;
}

.ilei-message-header-toggle:hover {
    background: #e9ecef;
}

.ilei-message-header-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.ilei-message-type {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.ilei-message-date {
    color: #6c757d;
    font-size: 12px;
}

.ilei-newest-badge {
    background: #28a745;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.ilei-accordion-icon {
    color: #6c757d;
    font-size: 12px;
    font-weight: bold;
    transition: transform 0.2s ease;
}

.ilei-message-content-accordion {
    padding: 15px;
    background: #fff;
}

/* Remove old collapse styles */
.ilei-messages-collapsed,
.ilei-collapse-toggle,
.ilei-collapse-text,
.ilei-collapse-icon,
.ilei-all-messages,
.ilei-recent-messages,
.ilei-recent-separator {
    display: none !important;
} 

.ilei-email-chain-view .ilei-chain-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    margin-bottom: 20px;
}

.ilei-email-chain-view .ilei-chain-header h3 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 24px;
}

.ilei-email-chain-view .ilei-chain-subtitle {
    margin: 0 0 5px 0;
    color: #6c757d;
    font-size: 14px;
}

.ilei-email-chain-view .ilei-chain-role {
    margin: 0;
    color: #495057;
    font-weight: 600;
    font-size: 14px;
} 