/* Modern CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --success-color: #10b981;
    --success-hover: #059669;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --border-radius: 0.5rem;
    --border-radius-lg: 0.75rem;
    --border-radius-xl: 1rem;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--gray-700);
    line-height: 1.6;
    flex-shrink: 0;
}

.container {
    max-width: 90%;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.5rem;
    text-shadow: var(--shadow-lg);
}

.subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 300;
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

.webhook-container {
    flex: 1;
    min-width: 300px;
}

.webhook-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: all 0.2s ease;
    background: white;
}

.webhook-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-icon {
    font-size: 1.1rem;
}

/* Main Container */
.main-container {
    display: grid;
    grid-template-columns: 30% 70%;
    background: white;
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

/* Section Headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    height: 10%;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
}

.count-badge {
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    min-width: 1.5rem;
    text-align: center;
}

/* Email List */
.email-list-container {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    max-height: 70vh;
}

.email-list-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.email-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.email-item {
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.email-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.email-item.selected {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(99, 102, 241, 0.1) 100%);
    box-shadow: var(--shadow-md);
}

.email-subject {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.email-from {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.email-date {
    color: var(--gray-400);
    font-size: 0.75rem;
}

/* Selected Email Container */
.selected-email-container {
    display: flex;
    flex-direction: column;
    max-height: 70vh;
    width: 100%;
}

.selected-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--gray-500);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.email-details {
    background: var(--gray-900);
    color: #10b981;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    white-space: pre-wrap;
    line-height: 1.5;
    box-shadow: inset var(--shadow);
    border: 1px solid var(--gray-800);
}

/* Process Actions */
.process-actions {
    padding: 1.5rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* Status Messages */
.status-message {
    margin-top: 1rem;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 500;
    display: none;
    animation: slideIn 0.3s ease;
}

.status-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.status-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading States */
.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1rem;
    height: 1rem;
    margin: -0.5rem 0 0 -0.5rem;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-container {
        grid-template-columns: 1fr;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    header h1 {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .main-container {
        border-radius: var(--border-radius);
    }
}

/* Email Display Styles */
.email-display {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.email-header {
    background: linear-gradient(135deg, var(--gray-50) 0%, white 100%);
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.email-display-subject {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 1rem;
    line-height: 1.4;
}

.email-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.meta-item {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.meta-item strong {
    color: var(--gray-700);
    margin-right: 0.5rem;
}

.email-body {
    padding: 1.5rem;
}

.email-body h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.email-content {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 1rem;
    white-space: pre-wrap;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: var(--gray-700);
    max-height: 300px;
    max-width: 100%;
    overflow-y: auto;
}

.email-attachments {
    padding: 0 1.5rem 1.5rem;
}

.email-attachments h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
}

.email-attachments ul {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    margin: 0;
    list-style: none;
}

.email-attachments li {
    padding: 0.25rem 0;
    color: var(--gray-600);
    font-size: 0.875rem;
}

.email-attachments li:before {
    content: "📎 ";
    margin-right: 0.5rem;
}

.email-raw-data {
    margin: 1.5rem;
    border-top: 1px solid var(--gray-200);
    padding-top: 1rem;
}

.email-raw-data summary {
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--gray-500);
    font-weight: 500;
    padding: 0.5rem 0;
    transition: color 0.2s ease;
}

.email-raw-data summary:hover {
    color: var(--primary-color);
}

.email-raw-data[open] summary {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* Webhook Response Styles */
.webhook-response {
    margin-top: 2rem;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 2px solid var(--success-color);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    animation: slideInResponse 0.5s ease;
}

.webhook-response h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #065f46;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.response-content {
    background: white;
    border-radius: var(--border-radius);
    padding: 1rem;
    border: 1px solid #a7f3d0;
}

.response-text {
    color: #065f46;
    line-height: 1.6;
    white-space: pre-wrap;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.response-json {
    background: var(--gray-900);
    color: #10b981;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    padding: 1rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    white-space: pre;
    line-height: 1.5;
    margin: -1rem;
    margin-top: 0;
}

/* Scrollbar Styling */
.email-list-wrapper::-webkit-scrollbar,
.selected-content::-webkit-scrollbar,
.email-details::-webkit-scrollbar,
.email-content::-webkit-scrollbar {
    width: 6px;
}

.email-list-wrapper::-webkit-scrollbar-track,
.selected-content::-webkit-scrollbar-track,
.email-details::-webkit-scrollbar-track,
.email-content::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 3px;
}

.email-list-wrapper::-webkit-scrollbar-thumb,
.selected-content::-webkit-scrollbar-thumb,
.email-content::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.email-details::-webkit-scrollbar-thumb {
    background: var(--gray-600);
    border-radius: 3px;
}

.email-list-wrapper::-webkit-scrollbar-thumb:hover,
.selected-content::-webkit-scrollbar-thumb:hover,
.email-details::-webkit-scrollbar-thumb:hover,
.email-content::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}