/* ==========================================================================
   DESIGN SYSTEM - DARK MODE GLASSMORPHISM
   ========================================================================== */

:root {
    --bg-main: #060913;
    --bg-card: rgba(13, 19, 39, 0.65);
    --border-card: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(99, 102, 241, 0.3);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Neon Accents */
    --accent-indigo: #6366f1;
    --accent-purple: #a855f7;
    --accent-rose: #f43f5e;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-cyan: #06b6d4;
    
    /* Glow Shadows */
    --shadow-indigo: 0 8px 32px 0 rgba(99, 102, 241, 0.15);
    --shadow-emerald: 0 8px 32px 0 rgba(16, 185, 129, 0.15);
    --shadow-rose: 0 8px 32px 0 rgba(244, 63, 94, 0.15);
    --shadow-purple: 0 8px 32px 0 rgba(168, 85, 247, 0.15);
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base resets & typography */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Styled Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-indigo);
}

/* Dashboard Container Layout */
.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* ==========================================================================
   HEADER SECTION
   ========================================================================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    gap: 1.5rem;
}

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

.logo-badge {
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
    border-radius: 12px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #c7d2fe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

.date-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--accent-indigo);
    font-weight: 600;
}

.last-updated {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Glassmorphism Generic Card */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-card);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
}

/* ==========================================================================
   KPI SUMMARY CARDS
   ========================================================================== */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.summary-cards .card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    cursor: default;
}

.summary-cards .card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
}

.card-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-content h3 {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-content .stat {
    font-size: 1.8rem;
    font-weight: 800;
    margin-top: 0.25rem;
    letter-spacing: -1px;
}

/* Glow effects on summary cards */
.card-glow {
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    filter: blur(40px);
    top: -50px;
    right: -50px;
    opacity: 0.15;
    pointer-events: none;
    transition: var(--transition-smooth);
}

.summary-cards .card:hover .card-glow {
    opacity: 0.3;
}

.total-glow { background-color: var(--accent-indigo); }
.success-glow { background-color: var(--accent-emerald); }
.error-glow { background-color: var(--accent-rose); }
.channel-glow { background-color: var(--accent-purple); }

/* KPI Custom Stat colors */
#total-tasks { color: #ffffff; }
#success-rate-kpi { color: var(--accent-emerald); text-shadow: 0 0 10px rgba(16, 185, 129, 0.2); }
#failed-tasks-kpi { color: var(--accent-rose); text-shadow: 0 0 10px rgba(244, 63, 94, 0.2); }
#unique-channels { color: var(--accent-purple); }

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.88rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-smooth);
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn.primary {
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
    border: none;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

.btn.primary:hover {
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

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

/* ==========================================================================
   TAB NAVIGATION
   ========================================================================== */
.tab-nav {
    display: flex;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    padding: 0.4rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-smooth);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
    color: #ffffff;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.1);
}

/* ==========================================================================
   FILTERS BAR
   ========================================================================== */
.filters-bar {
    display: flex;
    gap: 1rem;
    align-items: center;
    background: rgba(13, 19, 39, 0.4);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group.search-group {
    flex: 2;
    min-width: 300px;
}

.filters-bar input[type="text"],
.filters-bar select {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.88rem;
    outline: none;
    transition: var(--transition-smooth);
}

.filters-bar input[type="text"]:focus,
.filters-bar select:focus {
    border-color: var(--accent-indigo);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.filters-bar select option {
    background-color: var(--bg-main);
    color: var(--text-primary);
}

.result-count {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ==========================================================================
   TAB CONTENT LAYOUTS
   ========================================================================== */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   CHARTS GRID LAYOUT
   ========================================================================== */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.charts-section .chart-container {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.charts-section .chart-container.double-width {
    grid-column: span 2;
}

@media (max-width: 900px) {
    .charts-section .chart-container.double-width {
        grid-column: span 1;
    }
}

.chart-container h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    border-left: 3px solid var(--accent-indigo);
    padding-left: 0.75rem;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 300px;
    flex-grow: 1;
}

/* Circular Gauge Layout */
.gauge-chart-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: 250px;
}

.gauge-container {
    position: relative;
    width: 220px;
    height: 220px;
}

.gauge-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent-emerald);
    text-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

/* ==========================================================================
   TABLES & SUMMARIES (OVERVIEW TAB)
   ========================================================================== */
.tables-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

@media (max-width: 600px) {
    .tables-section {
        grid-template-columns: 1fr;
    }
}

.table-container {
    padding: 1.5rem;
}

.table-container h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    border-left: 3px solid var(--accent-purple);
    padding-left: 0.75rem;
}

.table-wrapper {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

th {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-weight: 600;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Inline progress bar in table */
.progress-bar-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-bar-bg {
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.05);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    max-width: 100px;
}

.progress-bar-fill {
    background: linear-gradient(to right, var(--accent-indigo), var(--accent-emerald));
    height: 100%;
    border-radius: 3px;
}

/* ==========================================================================
   DRILLDOWNS & ACCORDIONS (ERROR DETAILS TABS)
   ========================================================================== */
.table-section {
    padding: 2rem;
}

.table-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    border-left: 3px solid var(--accent-rose);
    padding-left: 0.75rem;
}

.drilldown-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.accordion-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.accordion-item:hover {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.accordion-header {
    padding: 0.88rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    gap: 1rem;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.92rem;
    word-break: break-all;
}

.accordion-icon {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    display: inline-block;
}

.accordion-item.active > .accordion-header > .header-title > .accordion-icon {
    transform: rotate(90deg);
    color: var(--text-primary);
}

.badge-count {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
}

/* Accordion nested container */
.accordion-content {
    display: none;
    padding: 0 1.25rem 1rem 1.25rem;
    background: rgba(0, 0, 0, 0.15);
}

.accordion-item.active > .accordion-content {
    display: block;
}

.group-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Drilldown Levels Accent lines & margins */
.level-1 { border-left: 3px solid var(--accent-indigo); }
.level-2 { border-left: 3px solid var(--accent-purple); margin-left: 0.25rem; }
.level-3 { border-left: 3px solid var(--accent-rose); margin-left: 0.5rem; }
.level-4 { border-left: 3px solid var(--accent-amber); margin-left: 0.75rem; }

/* ==========================================================================
   TASK LIST (LEAF LEVEL DATA ROW)
   ========================================================================== */
.task-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.task-row {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.task-row:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.05);
}

/* Clickable Copy elements */
.copyable {
    cursor: copy;
    font-family: monospace;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.04);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    color: var(--text-primary);
    transition: var(--transition-smooth);
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.copyable:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
    color: #ffffff;
}

/* Empty State visual */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    gap: 0.5rem;
}

.empty-state .icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

/* ==========================================================================
   TOAST NOTIFICATION
   ========================================================================== */
.toast {
    position: fixed;
    bottom: 2.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(13, 22, 44, 0.9);
    border: 1px solid rgba(16, 185, 129, 0.4);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(16, 185, 129, 0.1);
    color: var(--accent-emerald);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 1000;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

/* ==========================================================================
   LOADING OVERLAY & SPINNER
   ========================================================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-main);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(99, 102, 241, 0.1);
    border-left-color: var(--accent-indigo);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive adjust */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
    }
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
}
