/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #767676;
    --border-color: #d0d0d0;
    --border-light: #e8e8e8;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --error-bg: #fee;
    --error-border: #fcc;
    --error-text: #c00;
    --drop-zone-bg: #f5f5f5;
    --drop-zone-border: #ccc;
    --drop-zone-active: #e3f2fd;
    --overlay-bg: rgba(37, 99, 235, 0.95);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.1);
}

body {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
}

/* App Container */
.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.app-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.commit-date {
    font-size: 8pt;
    color: var(--text-muted);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.clear-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Queue Status */
.queue-status {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
}

.queue-status.hidden {
    display: none;
}

.queue-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.queue-label {
    font-weight: 600;
    color: var(--text-primary);
}

.queue-count {
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.queue-separator {
    color: var(--text-muted);
}

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

.queue-state.processing {
    color: var(--accent-color);
    font-weight: 500;
}

.queue-details {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.queue-details.hidden {
    display: none;
}

.queue-item {
    display: flex;
    gap: 8px;
}

.queue-item-label {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 80px;
}

.queue-item-value {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main Content */
.main-content {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Initial Drop Zone */
.initial-drop-zone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--drop-zone-border);
    border-radius: 8px;
    background: var(--drop-zone-bg);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 400px;
}

.initial-drop-zone:hover,
.initial-drop-zone.drag-over {
    border-color: var(--accent-color);
    background: var(--drop-zone-active);
}

.initial-drop-zone.hidden {
    display: none;
}

.drop-zone-content {
    text-align: center;
    padding: 40px;
}

.drop-icon {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.drop-zone-text {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.drop-zone-subtext {
    font-size: 14px;
    color: var(--text-muted);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.drop-zone-description {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    max-width: 500px;
    margin: 20px auto 0;
    line-height: 1.5;
}

.drop-zone-privacy {
    font-size: 12px;
    color: var(--text-muted);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    max-width: 500px;
    margin: 12px auto 0;
    line-height: 1.5;
}

.drop-zone-privacy a {
    color: var(--accent-color);
    text-decoration: none;
}

.drop-zone-privacy a:hover {
    text-decoration: underline;
}

/* Email Chain */
.email-chain {
    flex: 1;
    overflow-y: auto;
    background: transparent;
    border: none;
    padding: 20px 0;
}

.email-chain.hidden {
    display: none;
}

.email-chain.drag-over {
    background: var(--drop-zone-active);
}

/* Email Card - Individual Email Message */
.email-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 20px 24px;
    margin-bottom: 28px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08),
                0 1px 3px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    max-width: 85%;
    position: relative;
}

.email-card:last-child {
    margin-bottom: 0;
}

.email-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12),
                0 2px 4px rgba(0, 0, 0, 0.08);
}

/* Alternating left/right alignment */
.email-card-left {
    margin-left: 0;
    margin-right: auto;
}

.email-card-right {
    margin-left: auto;
    margin-right: 0;
}

/* Source File Badge */
.email-source-badge {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-primary);
    padding: 4px 10px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 14px;
    border: 1px solid var(--border-light);
}

/* Email Item */
.email-item {
    /* No bottom margin/padding/border since each card is separate now */
}

.email-header {
    margin-bottom: 12px;
}

.email-meta {
    display: grid;
    gap: 4px;
    margin-bottom: 14px;
    font-size: 14px;
    line-height: 1.4;
}

.email-meta-row {
    display: flex;
    align-items: baseline;
}

.email-meta-label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 60px;
    flex-shrink: 0;
    font-size: 13px;
}

.email-meta-value {
    color: var(--text-primary);
    word-break: break-word;
}

.email-subject {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 10px 0;
    line-height: 1.4;
}

.email-body {
    margin-top: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-primary);
    line-height: 1.6;
}

.email-attachments {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.email-attachments-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.email-attachments-list {
    list-style: none;
    font-size: 13px;
    color: var(--text-primary);
    padding-left: 0;
}

.email-attachments-list li {
    padding: 2px 0;
}

.email-attachments-list li:before {
    content: "📎 ";
    margin-right: 4px;
}

/* Drag Overlay */
.drag-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    pointer-events: none;
    z-index: 10;
}

.drag-overlay.hidden {
    display: none;
}

.drag-overlay-content {
    text-align: center;
    color: white;
}

.drag-overlay-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
}

.drag-overlay-text {
    font-size: 24px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-radius: 4px;
    padding: 14px 16px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.toast.hiding {
    animation: slideOut 0.3s ease-out forwards;
}

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

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    color: var(--error-text);
    font-size: 14px;
    margin-bottom: 4px;
}

.toast-message {
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--text-primary);
}

/* Scrollbar Styling */
.email-chain::-webkit-scrollbar {
    width: 10px;
}

.email-chain::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.email-chain::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

.email-chain::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 12px;
    }

    .email-chain {
        padding: 16px;
    }

    .toast-container {
        left: 12px;
        right: 12px;
        max-width: none;
    }
}
