/* ── DreamHost Process Monitor ── */
/* Dense, modern dark-mode aesthetic for high information density */

:root {
    /* Palette */
    --bg-base: #0b0d17;
    --bg-surface: #12152280;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-card-hover: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.14);

    --text-primary: #e8eaf0;
    --text-secondary: #8b8fa3;
    --text-muted: #555a70;

    /* Status colors */
    --green: #10b981;
    --green-bg: rgba(16, 185, 129, 0.08);
    --green-border: rgba(16, 185, 129, 0.2);

    --amber: #f59e0b;
    --amber-bg: rgba(245, 158, 11, 0.08);
    --amber-border: rgba(245, 158, 11, 0.2);

    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.08);
    --red-border: rgba(239, 68, 68, 0.2);

    --blue: #6366f1;
    --blue-bg: rgba(99, 102, 241, 0.08);
    --blue-border: rgba(99, 102, 241, 0.2);

    --slate: #64748b;
    --slate-bg: rgba(100, 116, 139, 0.08);

    /* Layout - Dense configuration */
    --max-width: 1560px;
    --radius: 8px;
    --radius-sm: 5px;

    /* Transitions */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────────── */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 10px 16px 8px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.logo svg {
    color: var(--blue);
}

.logo h1 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    font-weight: 500;
    padding: 2px 7px;
    border-radius: 12px;
    background: var(--blue-bg);
    color: var(--blue);
    border: 1px solid var(--blue-border);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.user-email-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-primary);
}

.user-logout {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: color 0.15s;
    margin-left: 2px;
}

.user-logout:hover {
    color: var(--red);
}

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

.last-check time {
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.74rem;
}

/* ── Refresh Indicator ──────────────────────────────────────── */

.refresh-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.refresh-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse-green 2s ease-in-out infinite;
}

/* ── Back Link ──────────────────────────────────────────────── */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: color 0.15s var(--ease);
}

.back-link:hover {
    color: var(--text-primary);
}

/* ── Time Range Selector ────────────────────────────────────── */

.time-range-selector {
    display: flex;
    gap: 2px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.time-btn {
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.15s var(--ease);
}

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

.time-btn.active {
    color: var(--text-primary);
    background: var(--blue-bg);
}

/* ── Buttons ────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.76rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s var(--ease);
    white-space: nowrap;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.74rem;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn.loading {
    position: relative;
    color: transparent !important;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    color: var(--text-primary);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}

.btn-danger {
    background: var(--red-bg);
    color: var(--red);
    border-color: var(--red-border);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.15);
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.12);
}

.btn-primary {
    background: #4f46e5;
    color: #fff;
    border-color: #6366f1;
}

.btn-primary:hover {
    background: #4338ca;
}

/* ── Summary Ribbon ─────────────────────────────────────────── */

.summary-bar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px 8px;
}

.summary-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(12px);
    height: 34px;
}

.summary-value {
    font-size: 1.15rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.summary-label {
    font-size: 0.67rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

/* ── Site Cards Grid ────────────────────────────────────────── */

.sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px 14px;
}

@media (min-width: 1240px) {
    .sites-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.site-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    backdrop-filter: blur(16px);
    transition: all 0.2s var(--ease);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.site-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

/* Status-specific card borders */
.site-card.site-healthy {
    border-left: 3px solid var(--green);
    --spark-color: var(--green);
}

.site-card.site-excess {
    border-left: 3px solid var(--red);
    background: var(--red-bg);
    --spark-color: var(--red);
}

.site-card.site-idle {
    border-left: 3px solid var(--text-muted);
    --spark-color: var(--text-muted);
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.site-name {
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.site-badges {
    display: flex;
    align-items: center;
    gap: 4px;
}

.site-domain {
    font-size: 0.67rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Alert Badge ────────────────────────────────────────────── */

.alert-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 5px;
    font-size: 0.62rem;
    font-weight: 700;
    color: #fff;
    background: var(--amber);
    border-radius: 8px;
    line-height: 1;
}

/* ── Status Badge ───────────────────────────────────────────── */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 7px;
    border-radius: 12px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.status-healthy {
    color: var(--green);
    background: var(--green-bg);
}

.status-healthy .status-dot {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
    animation: pulse-green 2s ease-in-out infinite;
}

.status-excess {
    color: var(--red);
    background: var(--red-bg);
}

.status-excess .status-dot {
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
    animation: pulse-red 1s ease-in-out infinite;
}

.status-idle {
    color: var(--text-muted);
    background: var(--slate-bg);
}

.status-idle .status-dot {
    background: var(--text-muted);
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; box-shadow: 0 0 3px var(--green); }
    50% { opacity: 0.6; box-shadow: 0 0 8px var(--green); }
}

@keyframes pulse-red {
    0%, 100% { opacity: 1; box-shadow: 0 0 3px var(--red); }
    50% { opacity: 0.4; box-shadow: 0 0 12px var(--red); }
}

/* ── Count & Sparkline Row ──────────────────────────────────── */

.count-spark-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 3px 0 5px;
}

.process-count {
    display: flex;
    align-items: baseline;
    gap: 3px;
    margin: 0;
}

.count-number {
    font-size: 1.35rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.site-healthy .count-number { color: var(--green); }
.site-excess .count-number { color: var(--red); }
.site-idle .count-number { color: var(--text-muted); }

.count-max {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.sparkline-wrap {
    flex: 1;
    max-width: 95px;
    height: 22px;
    margin: 0;
}

.sparkline {
    width: 100%;
    height: 22px;
}

/* ── Process List ───────────────────────────────────────────── */

.process-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-top: 1px solid var(--border);
    padding-top: 5px;
}

.process-list.empty {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    padding: 3px 0 1px;
}

.process-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.02);
}

.pid {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    color: var(--text-secondary);
}

.uptime {
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
}

/* ── Detail Page ────────────────────────────────────────────── */

.detail-hero {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 4px 16px 10px;
}

.detail-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
}

.detail-name {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.detail-domain {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 8px;
}

.detail-stats-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.detail-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    height: 34px;
}

.detail-stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.detail-stat-label {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.text-muted { color: var(--text-muted); }

.detail-section {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px 12px;
}

/* ── Chart ──────────────────────────────────────────────────── */

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    backdrop-filter: blur(16px);
}

.chart-container canvas {
    width: 100%;
    height: 120px;
    display: block;
}

/* ── Activity Section ───────────────────────────────────────── */

.activity-section {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 16px 20px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.section-title svg {
    color: var(--amber);
    flex-shrink: 0;
}

.activity-table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    backdrop-filter: blur(16px);
    max-height: 250px;
    overflow-y: auto;
}

.activity-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.activity-table thead th {
    text-align: left;
    padding: 6px 10px;
    font-size: 0.67rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: rgba(18, 21, 34, 0.95);
    position: sticky;
    top: 0;
    z-index: 1;
}

.activity-table tbody tr {
    transition: background 0.15s var(--ease);
}

.activity-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.activity-table td {
    padding: 4px 10px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.activity-table tbody tr:last-child td {
    border-bottom: none;
}

.mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
}

/* ── Site Link ──────────────────────────────────────────────── */

.site-link {
    color: var(--blue);
    text-decoration: none;
    font-weight: 500;
}

.site-link:hover {
    text-decoration: underline;
}

/* ── Action Badge ───────────────────────────────────────────── */

.action-badge {
    display: inline-block;
    font-size: 0.64rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 6px;
    border-radius: 4px;
}

.action-killed {
    color: var(--red);
    background: var(--red-bg);
}

.action-already_dead {
    color: var(--text-muted);
    background: var(--slate-bg);
}

.action-warning {
    color: var(--amber);
    background: var(--amber-bg);
}

.action-critical {
    color: var(--red);
    background: var(--red-bg);
}

.action-info {
    color: var(--blue);
    background: var(--blue-bg);
}

/* ── Empty State ────────────────────────────────────────────── */

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
}

.empty-state.small {
    padding: 20px 16px;
}

.empty-state svg {
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.82rem;
}

/* ── Toast ──────────────────────────────────────────────────── */

.toast {
    position: fixed;
    bottom: 16px;
    right: 16px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 500;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    transition: all 0.25s var(--ease);
    max-width: 360px;
}

.toast.hidden {
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
}

.toast-success {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid var(--green-border);
}

.toast-warning {
    background: var(--amber-bg);
    color: var(--amber);
    border: 1px solid var(--amber-border);
}

.toast-error {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid var(--red-border);
}

.toast-info {
    background: var(--blue-bg);
    color: var(--blue);
    border: 1px solid var(--blue-border);
}

/* ── Login View ─────────────────────────────────────────────── */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
    background: radial-gradient(circle at 50% 25%, rgba(99, 102, 241, 0.08), transparent 60%), var(--bg-base);
}

.login-container {
    width: 100%;
    max-width: 330px;
}

.login-card {
    background: rgba(18, 21, 34, 0.88);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius);
    padding: 22px 20px;
    backdrop-filter: blur(20px);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}

.login-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.login-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.login-error {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid var(--red-border);
    padding: 6px 9px;
    border-radius: var(--radius-sm);
    font-size: 0.74rem;
    margin-bottom: 12px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.form-input {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 9px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8rem;
    transition: all 0.15s var(--ease);
}

.form-input:focus {
    outline: none;
    border-color: var(--blue);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.login-btn {
    width: 100%;
    justify-content: center;
    padding: 7px;
    margin-top: 4px;
    font-size: 0.8rem;
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 900px) {
    .summary-bar {
        grid-template-columns: repeat(3, 1fr);
    }
    .detail-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .header {
        padding: 8px 12px;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .summary-bar {
        grid-template-columns: repeat(2, 1fr);
        padding: 0 12px 8px;
    }

    .sites-grid {
        grid-template-columns: 1fr;
        padding: 0 12px 14px;
    }

    .activity-section,
    .detail-section,
    .detail-hero {
        padding-left: 12px;
        padding-right: 12px;
    }

    .detail-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
