@import url('./styles/accordion.css');
@import url('./styles/quotePreview.css');
@import url('./styles/buttonLoading.css');
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    padding: 20px;
}

/* Main nav removed - no longer needed */

.dashboard-header {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 20px;
}

.view-switch-link {
    color: #64748b;
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.view-switch-link:hover {
    background: #f1f5f9;
    color: #1e40af;
}

.search-bar {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    min-width: 200px;
}

.search-bar:focus {
    outline: none;
    border-color: #3b82f6;
}

.stats-row {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.stat-urgent { color: #dc2626; }
.stat-today { color: #f59e0b; }
.stat-waiting { color: #6b7280; }

.priority-section {
    margin-bottom: 20px;
}

.section-header {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-urgent .section-header { color: #dc2626; }
.section-today .section-header { color: #f59e0b; }
.section-waiting .section-header { color: #6b7280; }

/* Loading States */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f4f6;
    border-radius: 50%;
    border-top-color: #3b82f6;
    animation: spin 1s ease-in-out infinite;
}

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

.loading-state {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.error-state {
    text-align: center;
    padding: 40px 20px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    margin: 20px 0;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
    background: white;
    border-radius: 8px;
    border: 2px dashed #e5e7eb;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .stats-row {
        justify-content: center;
    }
}

:root {
    --primary-color: #1e40af;
    --primary-hover: #1d4ed8;
    --accent-color: #2563eb;
    --success-color: #059669;
    --warning-color: #d97706;
    --error-color: #dc2626;
    --background-color: #f8fafc;
    --card-background: #ffffff;
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --hover-color: #f1f5f9;
    --navy-blue: #1e3a8a;
    --slate-gray: #475569;
    --split-left: 45%;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(30, 58, 138, 0.2));
}

.logo:hover {
    transform: scale(1.05);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.refresh-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    padding: 0;
    margin: 0;
}

.refresh-icon-btn:hover {
    background: rgba(30, 64, 175, 0.08);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.refresh-icon-btn:active {
    transform: translateY(0);
}

.refresh-icon-btn svg {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.refresh-icon-btn:hover svg {
    transform: rotate(360deg);
}

.refresh-icon-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.email-list {
    display: grid;
    gap: 1rem;
}

.email-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.08);
}

.email-card:hover {
    box-shadow: 0 8px 24px rgba(30, 58, 138, 0.15);
    transform: translateY(-2px);
    border-color: var(--navy-blue);
}

.email-card.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color);
}

.email-header {
    margin-bottom: 1rem;
}

.email-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.sender {
    display: flex;
    flex-direction: column;
}

.sender-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.938rem;
}

.sender-email {
    font-size: 0.813rem;
    color: var(--text-secondary);
    font-family: 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
}

.date {
    font-size: 0.813rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.email-subject {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-color);
    font-size: 1.063rem;
    line-height: 1.4;
}

.email-content {
    margin-bottom: 1rem;
}

.email-body {
    white-space: pre-wrap;
    margin-bottom: 1rem;
}

.suggested-response {
    background: var(--hover-color);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    position: relative;
}

.suggested-response::before {
    content: "💡 Voorgesteld antwoord:";
    display: block;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    font-style: normal;
    font-size: 0.813rem;
}

.response-content {
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.response-editor {
    width: 100%;
    min-height: 220px;
    flex: 1;
    padding: 0.75rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    background: transparent;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary);
    font-style: italic;
    resize: vertical;
    margin-bottom: 1rem;
    transition: all 0.25s ease;
}

.response-editor:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(30, 64, 175, 0.02);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
    font-style: normal;
    color: var(--text-color);
}

.response-editor:hover {
    border-color: rgba(30, 64, 175, 0.2);
}

.response-editor.modified {
    border-color: var(--warning-color);
    background: rgba(217, 119, 6, 0.02);
}

.response-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.response-send-btn {
    background: rgba(5, 150, 105, 0.12);
    color: var(--success-color);
    border-color: rgba(5, 150, 105, 0.3);
    font-weight: 600;
    padding: 0.5rem 1.25rem;
}

.response-send-btn:hover {
    background: rgba(5, 150, 105, 0.18);
    border-color: var(--success-color);
    color: #047857;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.2);
    transform: none;
}

.save-response-btn {
    background: rgba(217, 119, 6, 0.08);
    color: var(--warning-color);
    border-color: rgba(217, 119, 6, 0.2);
    margin-left: 0.5rem;
}

.save-response-btn:hover {
    background: rgba(217, 119, 6, 0.12);
    border-color: var(--warning-color);
    color: #c2410c;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.15);
}

.email-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn {
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.813rem;
    text-transform: none;
    letter-spacing: 0.025em;
    background: transparent;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.25);
}

.btn-approve {
    background: rgba(5, 150, 105, 0.08);
    color: var(--success-color);
    border-color: rgba(5, 150, 105, 0.2);
}

.btn-approve:hover {
    background: rgba(5, 150, 105, 0.12);
    border-color: var(--success-color);
    color: #047857;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.15);
}

.btn-modify {
    background: rgba(217, 119, 6, 0.08);
    color: var(--warning-color);
    border-color: rgba(217, 119, 6, 0.2);
}

.btn-modify:hover {
    background: rgba(217, 119, 6, 0.12);
    border-color: var(--warning-color);
    color: #c2410c;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.15);
}

.btn-complete {
    background: rgba(100, 116, 139, 0.08);
    color: var(--slate-gray);
    border-color: rgba(100, 116, 139, 0.2);
}

.btn-complete:hover {
    background: rgba(100, 116, 139, 0.12);
    border-color: var(--slate-gray);
    color: #334155;
    box-shadow: 0 2px 8px rgba(100, 116, 139, 0.15);
}

.btn-match-contact {
    background: rgba(30, 64, 175, 0.08);
    color: var(--primary-color);
    border-color: rgba(30, 64, 175, 0.2);
}

.btn-match-contact:hover {
    background: rgba(30, 64, 175, 0.12);
    border-color: var(--primary-color);
    color: var(--navy-blue);
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.15);
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 0.375rem;
}

/* Professional button states */
.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.btn:active {
    transform: translateY(1px);
}

.error-message {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 1rem;
    background: var(--error-color);
    color: white;
    border-radius: 0.375rem;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #64748b;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    background: var(--card-background);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: #64748b;
}

.empty-state p {
    color: #94a3b8;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.confirmation-dialog {
    background: var(--card-background);
    border-radius: 0.5rem;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.confirmation-dialog h2 {
    margin-bottom: 1.5rem;
}

.match-section {
    margin-bottom: 2rem;
}

.match-section h3 {
    margin-bottom: 1rem;
    color: #64748b;
}

.match-item {
    background: var(--hover-color);
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.match-item p {
    margin-bottom: 0.5rem;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.spinner-container {
    background: white;
    padding: 2rem;
    border-radius: 0.5rem;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.spinner-text {
    color: var(--text-color);
    font-weight: 500;
}

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

.email-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.footer-actions {
    display: flex;
    gap: 0.5rem;
}

.customer-info-footer {
    font-size: 0.875rem;
    color: #64748b;
    text-align: right;
}

.klantnaam {
    font-weight: 600;
    display: block;
}

.klantpersoon,
.klantemail {
    display: block;
    font-size: 0.8rem;
    color: #94a3b8;
}

/* Modal Styles */
.modal-overlay {
    display: none; /* Standaard verborgen */
    position: fixed; /* Blijf op dezelfde plek, zelfs bij scrollen */
    z-index: 1000; /* Zorg dat het boven alles staat */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Scrollen mogelijk maken als de content te groot is */
    background-color: rgba(0,0,0,0.5); /* Zwarte achtergrond met doorzichtigheid */
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
    animation-name: animatetop;
    animation-duration: 0.4s
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
}

.modal-header h2 {
    margin: 0;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    border: none;
    background: none;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-body {
    padding: 1rem 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.modal-body input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 1rem;
    margin-top: 1rem;
}

.match-container {
    max-height: 40vh;
    overflow-y: auto;
}

/* Animatie voor de modal */
@keyframes animatetop {
    from {top: -300px; opacity: 0}
    to {top: 0; opacity: 1}
} 

/* ===== THREAD INTERFACE STYLING ===== */

/* Tab Navigation */
.nav-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 2rem;
    gap: 0.5rem;
}

.nav-tab {
    background: transparent;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.nav-tab:hover {
    color: var(--primary-color);
    background-color: rgba(30, 64, 175, 0.05);
}

.nav-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Thread Interface Main Layout */
.thread-interface {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Thread Filters */
.thread-filters {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.filter-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: var(--card-background);
    color: var(--text-color);
    min-width: 120px;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.1);
}

#applyFilters, #clearFilters {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

#applyFilters {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

#applyFilters:hover {
    background: var(--primary-hover);
}

#clearFilters {
    background: var(--card-background);
    color: var(--text-color);
}

#clearFilters:hover {
    background: var(--hover-color);
}

/* Thread Statistics */
.thread-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.thread-stats .stat {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    text-align: center;
    transition: all 0.3s ease;
}

.thread-stats .stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.1);
}

.thread-stats .stat .number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.thread-stats .stat .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    font-weight: 500;
}

/* Thread Layout: 40% Timeline + 60% Canvas */
.thread-layout {
    display: grid;
    grid-template-columns: 40% 60%;
    gap: 1.5rem;
    min-height: 600px;
}

/* Timeline Panel (40%) */
.timeline-panel {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.timeline-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--hover-color);
}

.timeline-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

#newThreadBtn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

#newThreadBtn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.thread-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

/* Timeline Items */
.timeline-item {
    border-left: 3px solid var(--border-color);
    padding: 1rem 0 1rem 1rem;
    margin-left: 1rem;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
}

.timeline-item:hover {
    border-left-color: var(--primary-color);
}

.timeline-item.active {
    border-left-color: var(--primary-color);
    background: rgba(30, 64, 175, 0.05);
    margin-left: 0.5rem;
    margin-right: 0.5rem;
    border-radius: 0.5rem;
    padding-left: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 1.5rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--card-background);
    border: 3px solid var(--border-color);
    transition: all 0.3s ease;
}

.timeline-item.active::before {
    border-color: var(--primary-color);
    background: var(--primary-color);
}

.timeline-item.email::before {
    background: #3b82f6;
    border-color: #3b82f6;
}

.timeline-item.action::before {
    background: #10b981;
    border-color: #10b981;
}

.timeline-item.next-action::before {
    background: #f59e0b;
    border-color: #f59e0b;
}

.timeline-item.phone::before {
    background: #8b5cf6;
    border-color: #8b5cf6;
}

.timeline-content {
    margin-bottom: 0.5rem;
}

.timeline-title {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.timeline-description {
    color: var(--text-secondary);
    font-size: 0.813rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.timeline-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.timeline-status {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.625rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.timeline-status.new {
    background: #dbeafe;
    color: #1e40af;
}

.timeline-status.action_required {
    background: #fed7d7;
    color: #c53030;
}

.timeline-status.waiting {
    background: #fef3c7;
    color: #d97706;
}

.timeline-status.in_progress {
    background: #d1fae5;
    color: #065f46;
}

.timeline-status.completed {
    background: #e5e7eb;
    color: #374151;
}

.timeline-priority {
    font-weight: 600;
}

.timeline-priority.high {
    color: #dc2626;
}

.timeline-priority.medium {
    color: #d97706;
}

.timeline-priority.low {
    color: #059669;
}

.timeline-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.timeline-tag {
    background: var(--hover-color);
    color: var(--text-secondary);
    padding: 0.125rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.625rem;
    font-weight: 500;
}

/* Canvas Panel (60%) */
.canvas-panel {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.canvas-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--hover-color);
}

.canvas-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

.canvas-modes {
    display: flex;
    gap: 0.5rem;
}

.mode-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    background: var(--hover-color);
    color: var(--text-color);
}

.mode-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.canvas-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.canvas-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.canvas-placeholder p {
    font-size: 0.875rem;
    text-align: center;
}

/* Canvas Content Modes */
.canvas-overview {
    display: grid;
    gap: 1.5rem;
}

.overview-section {
    background: var(--hover-color);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
}

.overview-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.overview-emails {
    display: grid;
    gap: 0.75rem;
}

.overview-email {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-size: 0.875rem;
}

.overview-email-subject {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.overview-email-from {
    color: var(--text-secondary);
    font-size: 0.813rem;
}

.overview-actions {
    display: grid;
    gap: 0.5rem;
}

.overview-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.813rem;
}

.overview-action:last-child {
    border-bottom: none;
}

.overview-action-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

.overview-action-icon.email {
    background: #3b82f6;
}

.overview-action-icon.action {
    background: #10b981;
}

.overview-action-icon.phone {
    background: #8b5cf6;
}

.overview-next-actions {
    display: grid;
    gap: 0.5rem;
}

.overview-next-action {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-size: 0.875rem;
}

.overview-next-action.overdue {
    border-color: #dc2626;
    background: #fef2f2;
}

.overview-next-action.due-soon {
    border-color: #d97706;
    background: #fffbeb;
}

.overview-next-action-title {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.overview-next-action-due {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.overview-next-action.overdue .overview-next-action-due {
    color: #dc2626;
    font-weight: 600;
}

.overview-next-action.due-soon .overview-next-action-due {
    color: #d97706;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
    .thread-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .timeline-panel {
        max-height: 400px;
    }
    
    .thread-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .filter-group select {
        min-width: 100px;
    }
    
    .canvas-modes {
        flex-wrap: wrap;
    }
}

/* ===== ACTION BUTTONS & SUGGESTED ACTIONS ===== */

.suggested-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--card-background);
    color: var(--text-color);
    text-align: left;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.15);
}

.action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.action-btn-primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.action-btn-primary:hover {
    background: var(--primary-hover);
}

.action-btn-secondary {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.action-btn-secondary:hover {
    background: #047857;
}

.action-btn-tertiary {
    border-color: var(--border-color);
}

.action-btn-tertiary:hover {
    border-color: var(--primary-color);
    background: var(--hover-color);
}

.action-icon {
    font-size: 1.125rem;
    flex-shrink: 0;
}

.action-label {
    flex: 1;
}

.suggested-response-preview {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 1rem;
}

.suggested-response-preview h5 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
}

.response-text {
    color: var(--text-secondary);
    line-height: 1.5;
    font-size: 0.875rem;
}

/* ===== RESPONSE EDITOR ===== */

.response-editor-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
}

.email-context {
    background: var(--hover-color);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
}

.email-context h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.original-email {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
}

.email-header {
    font-size: 0.813rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.email-body {
    color: var(--text-color);
    line-height: 1.5;
    font-size: 0.875rem;
}

.response-editor-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.response-editor-section h4 {
    margin: 0 0 1rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.editor-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: var(--card-background);
    color: var(--text-color);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toolbar-btn:hover {
    background: var(--hover-color);
    border-color: var(--primary-color);
}

.response-textarea {
    flex: 1;
    min-height: 200px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-color);
    background: var(--card-background);
    resize: vertical;
    transition: border-color 0.3s ease;
}

.response-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.editor-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

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

.btn-tertiary {
    background: var(--card-background);
    color: var(--text-color);
    border-color: var(--border-color);
}

.btn-tertiary:hover {
    background: var(--hover-color);
    border-color: var(--primary-color);
}

.btn-icon {
    font-size: 1rem;
}

.btn-text {
    font-weight: 500;
}

.response-preview {
    background: var(--hover-color);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
}

.response-preview h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.email-preview {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
}

.email-preview-header {
    font-size: 0.813rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.email-preview-body {
    color: var(--text-color);
    line-height: 1.5;
    font-size: 0.875rem;
}

/* ===== TOAST NOTIFICATIONS ===== */

.toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 9999;
    max-width: 400px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.toast-show {
    transform: translateX(0);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    font-size: 0.875rem;
    font-weight: 500;
}

.toast-success .toast-content {
    background: var(--success-color);
    color: white;
}

.toast-error .toast-content {
    background: var(--error-color);
    color: white;
}

.toast-info .toast-content {
    background: var(--primary-color);
    color: white;
}

.toast-icon {
    font-size: 1.125rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    line-height: 1.4;
}

/* ===== EMAIL TO THREAD INTEGRATION ===== */

.convert-to-thread-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.813rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.convert-to-thread-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.ai-confidence {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--hover-color);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.ai-confidence.high {
    background: #d1fae5;
    border-color: #10b981;
    color: #065f46;
}

.ai-confidence.medium {
    background: #fef3c7;
    border-color: #d97706;
    color: #92400e;
}

.ai-confidence.low {
    background: #fef3c7;
    color: #92400e;
}

/* Reply Interface Styles */
.reply-modal {
    z-index: 1001;
}

.reply-modal-content {
    width: 95%;
    max-width: 1200px;
    max-height: 95vh;
    margin: 2vh auto;
    overflow-y: auto;
}

.reply-modal-body {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: 75vh;
    overflow-y: auto;
}

.reply-modal-footer {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--card-background);
}

.footer-left,
.footer-right {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Email Details Section */
.email-details-section {
    background: var(--hover-color);
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    margin: 1.5rem 1.5rem 0;
}

.email-details-section .email-header h3 {
    margin-bottom: 1rem;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
}

.email-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.email-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.from-info,
.subject-info,
.date-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.from-info strong,
.subject-info strong,
.date-info strong {
    color: var(--text-color);
    font-weight: 600;
}

.email-category {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.category-badge {
    padding: 0.25rem 0.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.confidence-badge {
    padding: 0.25rem 0.5rem;
    background: var(--success-color);
    color: white;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.email-content .email-body {
    background: var(--card-background);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    font-family: inherit;
    white-space: pre-wrap;
    line-height: 1.6;
    color: var(--text-color);
}

/* Reply Composer Section */
.reply-composer-section {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    margin: 0 1.5rem;
}

.composer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.composer-header h3 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
}

.composer-actions {
    display: flex;
    gap: 0.5rem;
}

.composer-actions .btn {
    font-size: 0.813rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
}

.composer-actions .icon {
    margin-right: 0.25rem;
}

.composer-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.salutation-section,
.response-editor-section,
.closing-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.salutation-section label,
.response-editor-section label,
.closing-section label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.875rem;
}

.salutation-input,
.closing-select {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--card-background);
    color: var(--text-color);
    transition: border-color 0.2s ease;
}

.salutation-input:focus,
.closing-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.reply-editor {
    min-height: 200px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    background: var(--card-background);
    color: var(--text-color);
    transition: border-color 0.2s ease;
}

.reply-editor:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.reply-editor::placeholder {
    color: var(--text-secondary);
}

/* AI Suggestion Section */
.ai-suggestion-section {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    margin: 0 1.5rem;
}

.suggestion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.suggestion-header h4 {
    margin: 0;
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 600;
}

.suggestion-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.confidence-indicator {
    padding: 0.25rem 0.5rem;
    background: var(--success-color);
    color: white;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.action-type {
    padding: 0.25rem 0.5rem;
    background: var(--accent-color);
    color: white;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.suggestion-content {
    padding: 1.5rem;
}

.suggested-response {
    background: var(--hover-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-color);
    white-space: pre-wrap;
    margin: 0;
}

.suggested-response::before {
    content: none;
}

/* Preview Section */
.preview-section {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    margin: 0 1.5rem;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.preview-header h4 {
    margin: 0;
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 600;
}

.preview-content {
    padding: 1.5rem;
}

.preview-email {
    background: var(--hover-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-color);
    white-space: pre-wrap;
}

/* Button Styles for Reply Interface */
.btn .icon {
    margin-right: 0.25rem;
    font-size: 0.875rem;
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.813rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .reply-modal-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    
    .reply-modal-body {
        max-height: calc(100vh - 140px);
    }
    
    .email-info {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .composer-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .composer-actions {
        flex-wrap: wrap;
        width: 100%;
        justify-content: flex-start;
    }
    
    .reply-modal-footer {
        flex-direction: column;
        gap: 1rem;
    }
    
    .footer-left,
    .footer-right {
        width: 100%;
        justify-content: center;
    }
}

/* Loading state for reply interface */
.reply-loading {
    opacity: 0.6;
    pointer-events: none;
}

.reply-loading .reply-editor,
.reply-loading .btn {
    cursor: not-allowed;
}

/* Success/Error states */
.reply-success {
    border-color: var(--success-color);
    background: rgba(5, 150, 105, 0.02);
}

.reply-error {
    border-color: var(--error-color);
    background: rgba(220, 38, 38, 0.02);
}

/* ===== CANVAS MODES STYLES ===== */

/* Canvas Mode Content */
.canvas-mode-content {
    padding: 1.5rem;
    height: 100%;
    overflow-y: auto;
}

/* Overview Mode */
.overview-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

.summary-header h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.thread-badges {
    display: flex;
    gap: 0.5rem;
}

.status-badge, .priority-badge, .source-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status-badge.new {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-badge.action_required {
    background-color: #fed7d7;
    color: #c53030;
}

.status-badge.waiting {
    background-color: #fef3c7;
    color: #d97706;
}

.status-badge.in_progress {
    background-color: #d1fae5;
    color: #065f46;
}

.status-badge.completed {
    background-color: #f0f9ff;
    color: #0369a1;
}

.priority-badge.high {
    background-color: #fce7e6;
    color: #dc2626;
}

.priority-badge.medium {
    background-color: #fef3c7;
    color: #d97706;
}

.priority-badge.low {
    background-color: #ecfdf5;
    color: #059669;
}

.source-badge {
    background-color: var(--hover-color);
    color: var(--text-secondary);
}

.summary-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.meta-item {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.meta-item strong {
    color: var(--text-color);
}

.emails-timeline, .next-actions {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.25rem;
}

.emails-timeline h4, .next-actions h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 1rem 0;
}

.timeline-emails {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.timeline-email {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: var(--hover-color);
}

.timeline-email-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.timeline-email-content {
    flex: 1;
}

.timeline-email-subject {
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.timeline-email-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Editor Mode */
.editor-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 1.5rem;
}

.editor-header {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
}

.original-email-context {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.email-preview {
    flex: 1;
}

.email-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.from-name {
    font-weight: 600;
    color: var(--text-color);
}

.email-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.email-preview-body {
    background: var(--hover-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.4;
    max-height: 100px;
    overflow-y: auto;
}

.ai-insights {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
}

.confidence-badge, .category-badge, .action-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.confidence-badge {
    background-color: #d1fae5;
    color: #065f46;
}

.category-badge {
    background-color: #dbeafe;
    color: #1e40af;
}

.action-badge {
    background-color: #fef3c7;
    color: #d97706;
}

.reply-editor-section {
    flex: 1;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.editor-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.ai-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.ai-toggle input[type="checkbox"] {
    accent-color: var(--primary-color);
}

.toggle-text {
    font-weight: 500;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: var(--card-background);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.btn-icon:hover {
    background: var(--hover-color);
    color: var(--text-color);
    border-color: var(--primary-color);
}

.reply-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-field label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
}

.salutation-field, .closing-field {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
}

.salutation-field:focus, .closing-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.reply-textarea {
    flex: 1;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.2s ease;
}

.reply-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.editor-footer {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quote-preview-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.quote-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.quote-icon {
    font-size: 1rem;
}

.quote-text {
    color: var(--text-secondary);
}

.btn-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
}

.btn-link:hover {
    text-decoration: underline;
}

.editor-action-buttons {
    display: flex;
    gap: 0.75rem;
}

/* Attachments Mode */
.attachments-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    height: 100%;
}

.files-section, .n8n-chat-section {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.25rem;
}

.files-section {
    flex: 0 0 auto;
}

.n8n-chat-section {
    flex: 1;
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.section-header {
    display: block;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.section-header h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
}

.status-dot.online {
    background-color: #10b981;
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--hover-color);
}

.file-icon {
    font-size: 1.5rem;
}

.file-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.file-name {
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.875rem;
}

.file-size {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.file-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-messages {
    flex: 1;
    background: var(--hover-color);
    border-radius: 0.5rem;
    padding: 1rem;
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.chat-message.system {
    background: var(--card-background);
    border-radius: 0.5rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
}

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

.message-icon {
    font-size: 1rem;
}

.message-text {
    font-size: 0.875rem;
    color: var(--text-color);
}

.chat-input-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-input {
    display: flex;
    gap: 0.5rem;
}

.chat-input-field {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
}

.chat-input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.btn-send-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 1rem;
}

.btn-send-chat:hover {
    background: var(--primary-hover);
}

.chat-suggestions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.suggestion-btn {
    padding: 0.5rem 0.75rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Actions Mode */
.actions-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.actions-history, .quick-actions {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.25rem;
}

.actions-history h4, .quick-actions h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 1rem 0;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--hover-color);
    border-radius: 0.5rem;
}

.history-timestamp {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.history-action {
    font-size: 0.875rem;
    color: var(--text-color);
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.action-btn {
    padding: 1rem;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.action-btn:hover {
    background: var(--hover-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

/* Responsive Design for Canvas Modes */
@media (max-width: 768px) {
    .canvas-mode-content {
        padding: 1rem;
    }
    
    .original-email-context {
        flex-direction: column;
        gap: 1rem;
    }
    
    .ai-insights {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
    }
    
    .editor-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .editor-footer {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .attachments-layout {
        gap: 1.5rem;
    }
    
    .quick-actions-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
    
    .chat-suggestions {
        flex-direction: column;
    }
    
    .suggestion-btn {
        align-self: flex-start;
    }
}

/* ============================================
   OUTLOOK-STYLE LAYOUT
   ============================================ */

/* Split pane container */
.split-pane-layout {
    display: grid;
    background-color: var(--background-color);
    grid-template-columns: minmax(260px, var(--split-left)) 8px 1fr;
    min-width: 0;
    height: calc(100vh - 140px);
    gap: 0;
    border-top: 1px solid #e5e7eb;
}

/* Splitter between left and right panes */
.splitter {
    width: 8px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        #e2e8f0 20%, 
        #e2e8f0 80%, 
        transparent 100%
    );
    cursor: col-resize;
    position: relative;
    transition: background 0.2s ease;
    user-select: none;
    z-index: 10;
}

.splitter:hover {
    background: linear-gradient(90deg, 
        transparent 0%, 
        #3b82f6 20%, 
        #3b82f6 80%, 
        transparent 100%
    );
}

.splitter::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 40px;
    background: white;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.splitter:hover::before {
    opacity: 0.8;
}

.splitter.is-dragging {
    background: linear-gradient(90deg, 
        transparent 0%, 
        #2563eb 20%, 
        #2563eb 80%, 
        transparent 100%
    );
}

body.splitter-resizing {
    cursor: col-resize;
    user-select: none;
}

body.splitter-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
    pointer-events: none;
}

body.splitter-resizing .splitter {
    pointer-events: auto;
}

/* Left pane - Thread list */
.left-pane.thread-list {
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.left-pane.thread-list .thread-list-container {
    padding-bottom: 80px;
}

.thread-list-header {
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

    .thread-list-header h3 {
        margin: 0;
        font-size: 16px;
        font-weight: 600;
        color: #111827;
        white-space: nowrap;
    }
    
    .thread-list-header .stats-row {
        flex-wrap: nowrap;
        gap: 12px;
    }

.thread-list-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Thread list items - Compact Outlook style */
.thread-list-item {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    transition: background-color 0.15s ease;
    background: white;
}

    .thread-list-item:hover {
        background: #f3f4f6;
    }

    .thread-list-item.selected {
        background: #dbeafe;
        border-left: 3px solid #3b82f6;
    }

    .thread-list-item.unread .thread-item-subject {
        font-weight: 600;
    }

.thread-item-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.thread-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.thread-badges {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.thread-badge {
    font-size: 14px;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.2s ease;
    cursor: help;
}

.thread-badge:hover {
    opacity: 1;
    transform: scale(1.15);
}

.response-badge {
    filter: grayscale(0.3);
}

.quote-badge {
    filter: grayscale(0.2);
}

.sent-badge {
    filter: grayscale(0.1);
}

.thread-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.status-indicator {
    font-size: 12px;
    flex-shrink: 0;
}

.thread-customer {
    font-size: 13px;
    font-weight: 500;
    color: #111827;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.has-quote-badge {
    font-size: 14px;
    flex-shrink: 0;
}

.thread-item-subject {
    font-size: 12px;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.thread-item-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: #6b7280;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Thread mail history accordion */
.thread-mail-history {
    margin-top: 8px;
    border-radius: 8px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

.thread-mail-history.single-email {
    background: #f8fafc;
    border-color: #e5e7eb;
}

.thread-mail-history .mail-history-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    font-size: 12px;
    font-weight: 500;
    color: #1f2937;
    cursor: pointer;
    text-align: left;
}

.thread-mail-history .mail-history-icon {
    font-size: 14px;
}

.thread-mail-history .mail-history-summary {
    flex: 1;
}

.thread-mail-history .mail-history-updated {
    font-size: 11px;
    color: #6b7280;
}

.thread-mail-history .mail-history-chevron {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.thread-mail-history.expanded .mail-history-chevron {
    transform: rotate(180deg);
}

.thread-mail-history .mail-history-list {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease;
    position: relative;
}

.thread-mail-history.expanded .mail-history-list,
.thread-mail-history.single-email .mail-history-list {
    max-height: 600px;
    padding: 0 12px 12px 0;
}

.thread-mail-history.expanded .mail-history-list::before,
.thread-mail-history.single-email .mail-history-list::before {
    content: "";
    position: absolute;
    top: 12px;
    bottom: 12px;
    left: 20px;
    width: 2px;
    background: rgba(148, 163, 184, 0.6);
}

.thread-mail-history.single-email .mail-history-list::before {
    background: rgba(148, 163, 184, 0.4);
}

.mail-history-item {
    padding: 10px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    margin-left: 24px;
    position: relative;
}

.mail-history-item:last-child {
    border-bottom: none;
}


.mail-history-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 4px;
}

.mail-history-header.highlighted {
    background: #f1f5f9;
    border-radius: 6px;
    padding: 6px 8px;
    border-left: 2px solid #3b82f6;
}

.mail-header-left {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.mail-sender {
    font-weight: 600;
    color: #1f2937;
    font-size: 12px;
}

.mail-subject {
    font-size: 12px;
    font-weight: 500;
    color: #1f2937;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.mail-time {
    font-size: 11px;
}

.mail-status {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 9999px;
    padding: 2px 6px;
    font-weight: 600;
}

.mail-status.sent {
    background: #dcfce7;
    color: #047857;
}

.mail-status.pending {
    background: #fef3c7;
    color: #b45309;
}

.mail-preview {
    font-size: 12px;
    color: #4b5563;
    line-height: 1.5;
    margin: 8px 0 0 0;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    padding-right: 4px;
}

.mail-preview::-webkit-scrollbar {
    width: 4px;
}

.mail-preview::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 2px;
}

.mail-preview::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.mail-preview::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.thread-mail-history.single-email .mail-history-toggle {
    cursor: default;
}

.thread-mail-history.single-email .mail-history-chevron {
    display: none;
}

/* Status colors for list items */
.thread-list-item.urgent {
    border-left: 3px solid #ef4444;
}

.thread-list-item.today {
    border-left: 3px solid #f59e0b;
}

.thread-list-item.waiting {
    border-left: 3px solid #6b7280;
}

/* Right pane - Thread details */
.right-pane.thread-details {
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.no-selection-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    font-size: 14px;
}

/* Thread detail container */
.thread-detail-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Thread detail header */
.thread-detail-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: white;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.detail-header-main {
    flex: 1;
}

.detail-subject {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: #6b7280;
}

.detail-customer {
    color: #374151;
}

.detail-status {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

    .detail-status.urgent {
        background: #fee2e2;
        color: #991b1b;
    }

    .detail-status.today {
        background: #fef3c7;
        color: #92400e;
    }

    .detail-status.waiting {
        background: #f3f4f6;
        color: #374151;
    }

.detail-value {
    font-weight: 600;
    color: #059669;
}

/* Header action buttons */
.detail-header-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 8px 12px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.15s ease;
}

    .action-btn:hover {
        background: #e5e7eb;
        transform: translateY(-1px);
    }

/* Email timeline in detail view */
.thread-detail-container .email-timeline {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    background: #f9fafb;
}

.timeline-email-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

    .timeline-email-card .email-header {
        display: flex;
        justify-content: space-between;
        margin-bottom: 12px;
        padding-bottom: 12px;
        border-bottom: 1px solid #f3f4f6;
    }

    .timeline-email-card .sender-info {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .timeline-email-card .sender-name {
        font-weight: 600;
        font-size: 14px;
        color: #111827;
    }

    .timeline-email-card .sender-email {
        font-size: 12px;
        color: #6b7280;
    }

    .timeline-email-card .email-meta {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 4px;
        font-size: 12px;
        color: #6b7280;
    }

    .timeline-email-card .email-subject {
        font-size: 15px;
        font-weight: 600;
        margin: 0 0 8px 0;
        color: #111827;
    }

    .timeline-email-card .email-body {
        font-size: 14px;
        line-height: 1.6;
        color: #374151;
        white-space: pre-wrap;
    }

/* Reply pane at bottom */
.thread-detail-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.thread-detail-container .reply-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-top: 2px solid #e5e7eb;
    background: white;
    overflow-y: auto;
    min-height: 0;
}

.reply-pane .reply-pane-header {
    flex-shrink: 0;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: white;
}

.reply-pane .reply-content {
    padding: 24px;
    background: white;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.suggested-response-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 400px;
}

.suggested-response-section .response-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.suggested-response-section .response-header h4 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
}

.suggested-response-section .response-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.suggested-response-section .response-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.suggested-response-section .response-actions {
    flex-shrink: 0;
    display: flex;
    gap: 12px;
    margin-top: 16px;
}


/* Responsive adjustments */
@media (max-width: 1024px) {
    .split-pane-layout {
        grid-template-columns: minmax(220px, var(--split-left)) 6px 1fr;
    }
}

@media (max-width: 768px) {
    .split-pane-layout {
        grid-template-columns: 1fr;
    }

    .left-pane.thread-list {
        display: none;
    }

    /* Mobile: show back button in detail view */
}
