/* ==========================================
   CATI Live Monitor — Dashboard Theme
   Clean light-mode professional design
   ========================================== */

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-glass: rgba(0, 0, 0, 0.02);
    --bg-glass-hover: rgba(0, 0, 0, 0.04);

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border-color: #e2e8f0;
    --border-glow: rgba(99, 102, 241, 0.3);

    /* Status Colors */
    --color-available: #10b981;  /* Emerald */
    --color-oncall: #22c55e;     /* Green */
    --color-wrapup: #f59e0b;     /* Amber */
    --color-ringing: #06b6d4;    /* Cyan */
    --color-consulting: #6366f1; /* Indigo */
    --color-break: #8b5cf6;      /* Violet */
    --color-lunch: #f97316;      /* Orange */
    --color-meeting: #3b82f6;    /* Blue */
    --color-training: #0ea5e9;   /* Sky Blue */
    --color-systemissues: #ef4444; /* Red */
    --color-loggedin: #64748b;   /* Slate */
    --color-offline: #94a3b8;    /* Gray */

    --color-success: #16a34a;
    --color-danger: #dc2626;
    --color-info: #0891b2;
    --color-warning: #d97706;

    --accent: #4f46e5;
    --accent-glow: rgba(79, 70, 229, 0.2);

    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 12px rgba(79, 70, 229, 0.08);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html,
body {
    height: 100%;
    font-size: 17px; /* Increases base size from 16px to 17px, scaling all rem units up proportionately */
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app-root {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------- Dashboard Layout ---------- */
.dashboard {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Header ---------- */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    z-index: 100;
    gap: 16px;
}

.header-left {
    flex-shrink: 0;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 1.6rem;
    animation: pulse-glow 2s ease-in-out infinite;
}

.header-logo h1 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.logo-accent {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-center {
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}

.header-center::-webkit-scrollbar {
    display: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.header-clock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.clock-time {
    font-size: 1.1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.clock-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.refresh-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    background: #f1f5f9;
    color: var(--text-muted);
    border: 1px solid #e2e8f0;
}

.refresh-indicator--active {
    background: #f0fdf4;
    color: var(--color-success);
    border-color: #bbf7d0;
}

.refresh-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.refresh-indicator--active .refresh-dot {
    animation: pulse-live 1.5s ease-in-out infinite;
}

/* ---------- Stats Bar ---------- */
.stats-bar {
    display: flex;
    gap: 10px;
    padding: 2px 0;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    transition: all var(--transition);
    min-width: fit-content;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    background: var(--bg-glass-hover);
    transform: translateY(-1px);
}

.stat-card__icon {
    font-size: 1rem;
    line-height: 1;
}

.stat-card__content {
    display: flex;
    flex-direction: column;
}

.stat-card__value {
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.stat-card__label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

.stat-card--primary .stat-card__value {
    color: #4f46e5;
}

.stat-card--active .stat-card__value {
    color: var(--color-oncall);
}

.stat-card--idle .stat-card__value {
    color: var(--color-idle);
}

.stat-card--success .stat-card__value {
    color: var(--color-success);
}

.stat-card--info .stat-card__value {
    color: var(--color-info);
}

.stat-card--warning .stat-card__value {
    color: var(--color-warning);
}

.stat-card--rate .stat-card__value {
    color: #db2777;
}

.stat-card__pulse {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-oncall);
    animation: pulse-live 1.5s ease-in-out infinite;
}


.live-icon {
    margin-left: 6px;
    font-size: 14px;
    color: #4CAF50;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.4;
    }
}

/* ---------- Dashboard Body ---------- */
.dashboard-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 0;
}

/* ---------- Agent Grid ---------- */
.agent-grid-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 20px 24px;
}

.agent-grid-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.agent-grid-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pill {
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.pill:hover {
    background: var(--bg-glass-hover);
    color: var(--text-secondary);
}

.pill--active {
    background: #eef2ff !important;
    color: #4338ca !important;
    border-color: #c7d2fe !important;
}

.pill--oncall.pill--active {
    background: #22c55e !important;
    color: #ffffff !important;
    border-color: #16a34a !important;
}

.pill--preview.pill--active {
    background: #e0f2fe !important;
    color: #0369a1 !important;
    border-color: #bae6fd !important;
}

.pill--ringing.pill--active {
    background: #ecfeff !important;
    color: #0e7490 !important;
    border-color: #a5f3fc !important;
}
.pill--idle.pill--active {
    background: #f0fdf4 !important;
    color: #15803d !important;
    border-color: #bbf7d0 !important;
}

.pill--wrapup.pill--active {
    background: #fef08a !important;
    color: #a16207 !important;
    border-color: #fde047 !important;
}

.pill--break.pill--active {
    background: #faf5ff !important;
    color: #7e22ce !important;
    border-color: #d8b4fe !important;
}

.pill--offline.pill--active {
    background: #f9fafb !important;
    color: #374151 !important;
    border-color: #d1d5db !important;
}

.pill--callwaiting.pill--active {
    background: #fdf4ff !important;
    color: #a21caf !important;
    border-color: #f5d0fe !important;
}

.pill--loggedin.pill--active {
    background: #ecfdf5 !important;
    color: #047857 !important;
    border-color: #a7f3d0 !important;
}

.agent-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    padding-right: 8px;
    padding-bottom: 16px;
}

.agent-grid::-webkit-scrollbar {
    width: 5px;
}

.agent-grid::-webkit-scrollbar-track {
    background: transparent;
}

.agent-grid::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.agent-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid #f1f5f9; /* Paler shade of border */
    border-radius: 2px; /* Reduced to 2px */
    padding: 12px 20px;
    transition: all var(--transition);
}

.agent-card:hover {
    background: var(--bg-card-hover);
    border-color: #e2e8f0; /* Slightly darker on hover for contrast */
    box-shadow: var(--shadow-sm);
}

.agent-card--active {
    background: #f0f7ff;
}

.agent-card--active:hover {
    background: #e8f1fd;
}

.agent-card--preview {
    background: #f0fdfa;
}

.agent-card--preview:hover {
    background: #e6faf5;
}

.agent-card--offline {
    opacity: 0.5;
}

.agent-card--offline:hover {
    opacity: 0.7;
}

.agent-card__header {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
    width: 220px;
    flex-shrink: 0;
}

.agent-avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.agent-info {
    flex: 1;
    min-width: 0;
}

.agent-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-ext {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.call-count-badge {
    font-size: 0.6rem;
    font-weight: 600;
    color: #475569;
    background: #e2e8f0;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ---------- Status Badge ---------- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.675rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    text-transform: uppercase;
}

.status-icon {
    font-size: 0.675rem;
    flex-shrink: 0;
    line-height: 1;
}

.status-available {
    background: #ecfdf5;
    color: #059669;
}

.status-oncall {
    background: #22c55e;
    color: #ffffff;
}

.status-preview {
    background: #e0f2fe;
    color: #0369a1;
}

.status-ringing {
    background: #ecfeff;
    color: #0e7490;
    animation: status-pulse-cyan 2s infinite;
}

.status-callwaiting {
    background: #eef2ff;
    color: #4338ca;
}

.status-wrapup {
    background: #fef08a;
    color: #a16207;
}

.status-break {
    background: #f5f3ff;
    color: #7c3aed;
}

.status-lunch {
    background: #fff7ed;
    color: #c2410c;
}

.status-meeting {
    background: #eff6ff;
    color: #1d4ed8;
}

.status-training {
    background: #f0f9ff;
    color: #0369a1;
}

.status-systemissues {
    background: #fef2f2;
    color: #b91c1c;
}

.status-loggedin {
    background: #f8fafc;
    color: #475569;
}

.status-offline {
    background: #f1f5f9;
    color: #94a3b8;
}

@keyframes status-pulse-cyan {
    0% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(6, 182, 212, 0); }
    100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0); }
}

/* ---------- Call Info ---------- */
.agent-card__call-info {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 1;
    min-width: 0;
}

.call-detail {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 12px;
    border-left: 1px solid var(--border-color);
}

.call-detail:first-child {
    border-left: none;
    padding-left: 0;
}

/* Fixed widths for vertical alignment across rows */
.call-detail:nth-child(1) {
    width: 150px;
    flex-shrink: 0;
}

/* Caller */
.call-detail:nth-child(2) {
    width: 300px;
    flex-shrink: 0;
}

/* Survey */
.call-detail:nth-child(3) {
    width: 90px;
    flex-shrink: 0;
}

/* Call/Status Duration */
.call-detail:nth-child(4) {
    width: 90px;
    flex-shrink: 0;
}

/* Attempt */
.call-detail:nth-child(5) {
    width: 60px;
    flex-shrink: 0;
}

/* Call # */

.call-label {
    font-size: 0.58rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.call-value {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.call-value--survey {
    color: #4338ca;
    font-weight: 600;
}

.call-value--duration {
    font-variant-numeric: tabular-nums;
    color: var(--color-oncall);
    font-weight: 600;
}

.call-value--time {
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    font-weight: 500;
}

.call-value--alert {
    font-variant-numeric: tabular-nums;
    color: #dc2626;
    font-weight: 700;
    animation: alert-pulse 1s ease-in-out infinite;
}

.call-value--warning {
    font-variant-numeric: tabular-nums;
    color: #d97706; /* Amber */
    font-weight: 700;
    animation: warning-pulse 2s ease-in-out infinite;
}

@keyframes alert-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes warning-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7; /* Gentler dip than alert */
    }
}

/* ---------- Agent Stats Row ---------- */
.agent-card__stats {
    display: flex;
    gap: 16px;
    margin-left: auto;
    flex-shrink: 0;
}

.agent-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    min-width: 36px;
}

.stat-number {
    font-size: 0.82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.agent-stat--success .stat-number {
    color: var(--color-success);
}

.agent-stat--danger .stat-number {
    color: var(--color-danger);
}

.stat-label {
    font-size: 0.52rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

/* ---------- Activity Feed Sidebar ---------- */
.activity-sidebar {
    width: 320px;
    flex-shrink: 0;
    border-left: 1px solid var(--border-color);
    background: var(--bg-secondary);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.activity-feed {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.activity-feed__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.activity-feed__header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--color-danger);
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-danger);
    animation: pulse-live 1s ease-in-out infinite;
}

.activity-feed__list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.activity-feed__list::-webkit-scrollbar {
    width: 3px;
}

.activity-feed__list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.activity-feed__empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 20px;
    transition: background var(--transition);
    border-left: 2px solid transparent;
}

.activity-item:hover {
    background: var(--bg-glass-hover);
}

.activity-item--call {
    border-left-color: var(--color-oncall);
}

.activity-item--success {
    border-left-color: var(--color-success);
}

.activity-item--danger {
    border-left-color: var(--color-danger);
}

.activity-item--online {
    border-left-color: var(--color-idle);
}

.activity-item--offline {
    border-left-color: var(--color-offline);
}

.activity-item--break {
    border-left-color: var(--color-break);
}

.activity-item--info {
    border-left-color: var(--color-info);
}

.activity-icon {
    font-size: 0.9rem;
    line-height: 1.4;
    flex-shrink: 0;
}

.activity-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.activity-text {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.4;
    word-wrap: break-word;
}

.activity-time {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ---------- Animations ---------- */
@keyframes pulse-live {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(0.85);
    }
}

@keyframes pulse-glow {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.3);
    }
}

@keyframes slide-in-right {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.activity-item {
    animation: slide-in-right 0.3s ease-out;
}

/* ---------- Blazor Error UI ---------- */
#blazor-error-ui {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    padding: 12px 24px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: none;
    font-family: var(--font);
    font-size: 0.8rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    text-decoration: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .activity-sidebar {
        width: 280px;
    }
}

@media (max-width: 900px) {
    .dashboard-header {
        flex-wrap: wrap;
        padding: 10px 16px;
    }

    .header-center {
        order: 3;
        flex-basis: 100%;
    }

    .activity-sidebar {
        display: none;
    }

    .agent-grid {
        flex-direction: column;
    }
}

@media (max-width: 600px) {
    .agent-grid {
        flex-direction: column;
    }

    .agent-card {
        flex-wrap: wrap;
    }

    .agent-card__header {
        min-width: unset;
    }

    .agent-card__stats {
        margin-left: 0;
    }

    .stats-bar {
        gap: 6px;
    }

    .stat-card {
        padding: 4px 10px;
    }

    .filter-pills {
        gap: 4px;
    }
}