/* static/css/pipeline_layout.css */

/* Page layout wrappers */
.pipeline-wrapper {
    display: none; /* Hidden by default. JS sets to 'flex'. */
    flex-direction: column;
    height: calc(100vh - 70px);
}

/* Pipeline Grid Layout */
.pipeline-grid {
    display: grid;
    /* Give the first column (scheduled) more space and prevent overflow */
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    min-height: 0;
    grid-template-areas: "scheduled pending queue recent";
    flex-grow: 1;
}

.pipeline-column {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-alt);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    min-width: 0;
    min-height: 0;
    position: relative;
}

[data-column-id="scheduled"] { grid-area: scheduled; }
[data-column-id="pending-container"] { grid-area: pending; }
[data-column-id="queue"] { grid-area: queue; }
[data-column-id="recent"] { grid-area: recent; }

.column-header {
    padding: 0.75rem 1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.column-header .count {
    font-size: 0.8em;
    padding: 2px 6px;
    border-radius: 1rem;
    background-color: var(--surface);
    color: var(--text-muted);
    font-weight: 700;
}

.column-body {
    flex-grow: 1;
    padding: 1rem;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scrollbar */
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative; /* For the timeline pseudo-element */
}

/* Recent Sent/Failed column styles */
.recent-container { padding: 0; background: transparent; border: none; gap: 1.5rem; }
.sub-section { display: flex; flex-direction: column; background-color: var(--bg-alt); border-radius: 0.75rem; border: 1px solid var(--border); min-height: 0; flex: 1; }
.sub-section .column-body { padding: 1rem; }

/* Scrollbars */
.column-body::-webkit-scrollbar, .log-body::-webkit-scrollbar { width: 8px; }
.column-body::-webkit-scrollbar-track, .log-body::-webkit-scrollbar-track { background: transparent; }
.column-body::-webkit-scrollbar-thumb, .log-body::-webkit-scrollbar-thumb { background-color: var(--surface-alt); border-radius: 4px; border: 2px solid var(--bg-alt); }
body:not(.dark) .column-body::-webkit-scrollbar-thumb, body:not(.dark) .log-body::-webkit-scrollbar-thumb { border: 2px solid var(--surface); }
.column-body::-webkit-scrollbar-thumb:hover, .log-body::-webkit-scrollbar-thumb:hover { background-color: var(--text-muted); }

/* Email View Modal */
#email-view-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.email-view-modal-content {
    background: var(--bg);
    border-radius: 0.75rem;
    width: 100%;
    height: 100%;
    max-width: 90vw;
    max-height: 90vh;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    animation: scaleIn 0.3s ease;
}
@keyframes scaleIn { from { transform: scale(0.95); } to { transform: scale(1); } }

body.dark .email-view-modal-content { background: var(--bg-alt); }

.email-view-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

body.dark .email-view-modal-header { background: var(--surface-alt); }

.email-view-modal-title {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-view-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s, transform 0.2s;
}

.email-view-modal-close:hover {
    background: var(--danger-light);
    color: var(--danger-text);
    transform: rotate(90deg);
}

.email-view-modal-body {
    flex-grow: 1;
    overflow: hidden;
    position: relative;
}

.email-view-modal-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 1.2rem;
    color: var(--text-muted);
}

#email-view-modal iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* --- Responsive Grid Layout --- */
@media (max-width: 1200px) {
    .pipeline-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "scheduled pending"
            "queue recent";
    }
}

@media (max-width: 768px) {
    .pipeline-wrapper {
        height: auto; /* Allow scrolling on mobile */
        overflow-y: auto;
    }
    .pipeline-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "scheduled"
            "pending"
            "queue"
            "recent";
        padding: 1rem;
        gap: 1rem;
    }
}