/* ==============================================================================
   Rally OpenStack Monitor - Dashboard Styles
   Modern dark glassmorphism design
   ============================================================================== */

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(99, 102, 241, 0.3);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-indigo: #6366f1;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-red: #ef4444;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;

    --success: #10b981;
    --failure: #ef4444;
    --pending: #64748b;
    --warning: #f59e0b;

    --gradient-primary: linear-gradient(135deg, #6366f1, #06b6d4);
    --gradient-success: linear-gradient(135deg, #10b981, #059669);
    --gradient-failure: linear-gradient(135deg, #ef4444, #dc2626);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(6, 182, 212, 0.06) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

section,
header,
footer {
    position: relative;
    z-index: 1;
}

/* --- Header --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    animation: pulse-glow 3s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
    from {
        filter: drop-shadow(0 0 4px rgba(99, 102, 241, 0.3));
    }

    to {
        filter: drop-shadow(0 0 12px rgba(6, 182, 212, 0.5));
    }
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.health-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    border-radius: 100px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    font-size: 0.8rem;
    font-weight: 600;
    transition: var(--transition);
}

.health-badge.healthy {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.08);
}

.health-badge.unhealthy {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.08);
}

.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition);
}

.health-badge.healthy .health-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: dot-pulse 2s ease-in-out infinite;
}

.health-badge.unhealthy .health-dot {
    background: var(--failure);
    box-shadow: 0 0 8px var(--failure);
    animation: dot-pulse 1s ease-in-out infinite;
}

@keyframes dot-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

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

/* --- Sections --- */
section {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.section-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
}

.section-badge.ok {
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.3);
}

.section-badge.error {
    color: var(--failure);
    border-color: rgba(239, 68, 68, 0.3);
}

/* --- 7-Day Timeline --- */
.timeline-container {
    display: flex;
    gap: 3px;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(10px);
    overflow: hidden;
    min-height: 56px;
    align-items: stretch;
}

.timeline-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.timeline-cell {
    flex: 1 1 0;
    min-width: 2px;
    height: 36px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.timeline-cell:hover {
    transform: scaleY(1.3);
    z-index: 2;
}

.timeline-cell.passed {
    background: var(--gradient-success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.3);
}

.timeline-cell.failed {
    background: var(--gradient-failure);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.3);
}

.timeline-cell.pending {
    background: rgba(100, 116, 139, 0.3);
    border: 1px dashed rgba(100, 116, 139, 0.4);
}

/* Selected cell ring (click-to-inspect historical run) */
.timeline-cell.selected {
    outline: 2px solid #f59e0b;
    outline-offset: 2px;
    z-index: 3;
    transform: scaleY(1.4);
}

.timeline-cell.selected .timeline-tooltip {
    opacity: 1;
}

.timeline-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
    box-shadow: var(--shadow-md);
}

.timeline-cell:hover .timeline-tooltip {
    opacity: 1;
}

.timeline-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
    padding-left: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.legend-passed {
    background: var(--success);
}

.legend-failed {
    background: var(--failure);
}

.legend-pending {
    background: var(--pending);
}

/* --- Service Cards --- */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.service-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.service-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition);
}

.service-card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.service-card:hover::before {
    opacity: 1;
}

.service-card.status-passed {
    border-left: 3px solid var(--success);
}

.service-card.status-failed {
    border-left: 3px solid var(--failure);
}

.service-card.status-pending {
    border-left: 3px solid var(--pending);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: capitalize;
}

.card-icon {
    font-size: 1.25rem;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-chip.passed {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.status-chip.failed {
    background: rgba(239, 68, 68, 0.12);
    color: var(--failure);
}

.status-chip.pending {
    background: rgba(100, 116, 139, 0.12);
    color: var(--pending);
}

.card-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.metric {
    text-align: center;
}

.metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Per-service mini timeline */
.card-timeline {
    display: flex;
    gap: 2px;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-glass);
}

.card-timeline-cell {
    flex: 1;
    height: 6px;
    border-radius: 2px;
    transition: var(--transition);
}

.card-timeline-cell.passed {
    background: var(--success);
}

.card-timeline-cell.failed {
    background: var(--failure);
}

.card-timeline-cell.pending {
    background: rgba(100, 116, 139, 0.3);
}

/* --- Live API Health Indicator (per service card) --- */
.live-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.live-indicator.up .live-dot {
    background: var(--success);
    box-shadow: 0 0 5px rgba(16, 185, 129, 0.7);
    animation: livepulse 2s ease-in-out infinite;
}

.live-indicator.up {
    color: var(--success);
}

.live-indicator.down .live-dot {
    background: var(--failure);
    box-shadow: 0 0 5px rgba(239, 68, 68, 0.7);
}

.live-indicator.down {
    color: var(--failure);
}

.live-indicator.unknown .live-dot {
    background: var(--pending);
}

@keyframes livepulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(0.8); }
}

/* --- Charts --- */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1rem;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    backdrop-filter: blur(10px);
}

.chart-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.chart-card canvas {
    max-height: 250px;
}

/* --- Cleanup Status --- */
.cleanup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.cleanup-item {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
    backdrop-filter: blur(10px);
    transition: var(--transition);
}

.cleanup-item.has-orphans {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

.cleanup-service {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.cleanup-count {
    font-size: 1.5rem;
    font-weight: 700;
}

.cleanup-count.zero {
    color: var(--success);
}

.cleanup-count.nonzero {
    color: var(--failure);
}

.cleanup-label {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: capitalize;
}

.modal-close {
    background: none;
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--failure);
}

.modal-body {
    padding: 1.5rem;
}

.scenario-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    transition: var(--transition);
}

.scenario-row:hover {
    border-color: var(--border-glow);
}

.scenario-name {
    font-size: 0.8rem;
    font-weight: 500;
    flex: 1;
    word-break: break-all;
}

.scenario-stats {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-shrink: 0;
    margin-left: 1rem;
}

.scenario-stat {
    text-align: center;
}

.scenario-stat-value {
    font-size: 0.85rem;
    font-weight: 600;
}

.scenario-stat-label {
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* --- Historical Run Banner --- */
.historical-banner {
    max-width: 1400px;
    margin: -0.5rem auto 0;
    padding: 0 2rem;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.3s ease-out;
}

.historical-banner-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    color: var(--accent-amber);
}

.historical-banner-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

#historicalBannerText {
    flex: 1;
    font-weight: 500;
}

.back-to-latest-btn {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: var(--accent-amber);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.back-to-latest-btn:hover {
    background: rgba(245, 158, 11, 0.25);
    border-color: rgba(245, 158, 11, 0.6);
}

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--border-glass);
    margin-top: 2rem;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .header-left {
        justify-content: center;
    }

    .header-right {
        justify-content: center;
    }

    section {
        padding: 1rem;
    }

    .services-grid {
        grid-template-columns: 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Animations --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.service-card {
    animation: fadeInUp 0.4s ease-out backwards;
}

.service-card:nth-child(1) {
    animation-delay: 0.05s;
}

.service-card:nth-child(2) {
    animation-delay: 0.1s;
}

.service-card:nth-child(3) {
    animation-delay: 0.15s;
}

.service-card:nth-child(4) {
    animation-delay: 0.2s;
}

.service-card:nth-child(5) {
    animation-delay: 0.25s;
}

.service-card:nth-child(6) {
    animation-delay: 0.3s;
}

.service-card:nth-child(7) {
    animation-delay: 0.35s;
}

/* --- Health Check Timeline cells --- */
.htl-container {
    gap: 2px;
}

.htl-cell {
    flex: 1 1 0;
    min-width: 2px;
    height: 28px;
    border-radius: 3px;
    cursor: default;
    transition: var(--transition);
    position: relative;
}

.htl-cell:hover {
    transform: scaleY(1.3);
    z-index: 2;
}

.htl-cell:hover .timeline-tooltip {
    opacity: 1;
}

.htl-cell.up {
    background: var(--gradient-success);
    box-shadow: 0 0 4px rgba(16, 185, 129, 0.2);
}

.htl-cell.down {
    background: var(--gradient-failure);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.htl-cell.unknown {
    background: rgba(100, 116, 139, 0.3);
    border: 1px dashed rgba(100, 116, 139, 0.4);
}