/* ============================================================================
 *  pulsewatch.css — app-specific layout (dashboard, charts, slave UIs, etc.)
 *
 *  Cross-cutting components (buttons, navigation, modals, status pills,
 *  alerts, page headers, copy blocks, meta chips, form controls) now live
 *  in components.css; design tokens live in tokens.css. This file should
 *  reference --surface-*, --text-*, --accent-*, --status-*, --space-*
 *  tokens rather than raw colours.
 *
 *  Legacy --color-* aliases in tokens.css still resolve, so existing rules
 *  in this file that reference them keep working — but new code should use
 *  the semantic tokens directly.
 * ========================================================================= */

/* Dashboard auto-refresh control. Header is rendered by
 * components/page_header.html now; only the auto-refresh checkbox is
 * dashboard-specific. */
.auto-refresh {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}
.auto-refresh label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

/* Tables */
.targets-table,
.measurements-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface-1);
    box-shadow: var(--shadow-sm);
    border-radius: 4px;
    overflow: hidden;
}

.targets-table th,
.targets-table td,
.measurements-table th,
.measurements-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.targets-table th,
.measurements-table th {
    background: var(--color-bg-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.targets-table td,
.measurements-table td {
    font-size: 0.875rem;
}

.targets-table tr:last-child td,
.measurements-table tr:last-child td {
    border-bottom: none;
}

.targets-table tbody tr:hover,
.measurements-table tbody tr:hover {
    background: var(--color-bg);
}

/* Legacy badges — pre-component-system. Re-pointed at the new tokens so
 * they stay theme-aware; new templates should prefer components/status_pill.html
 * for letter-spaced caps or components/meta_chip.html for inline metadata. */
.badge {
    display: inline-block;
    padding: 2px var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge-ok    { background: var(--status-ok-bg);      color: var(--status-ok-fg);      border-color: var(--status-ok-border); }
.badge-warn  { background: var(--status-warn-bg);    color: var(--status-warn-fg);    border-color: var(--status-warn-border); }
.badge-crit  { background: var(--status-crit-bg);    color: var(--status-crit-fg);    border-color: var(--status-crit-border); }
.badge-off   { background: var(--status-neutral-bg); color: var(--status-neutral-fg); border-color: var(--status-neutral-border); }
.badge-local { background: var(--status-info-bg);    color: var(--status-info-fg);    border-color: var(--status-info-border); }
.badge-remote{ background: var(--surface-2);         color: var(--text-secondary);    border-color: var(--border-default); }

/* Target Detail — host metadata. Header is rendered by
 * components/page_header.html now. */
.target-host {
    font-family: var(--font-mono);
    background: var(--surface-2);
    padding: 2px var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    display: inline-block;
}

.target-description {
    color: var(--text-secondary);
    margin: 0;
}

.target-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.stat-card {
    background: var(--surface-1);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 1rem;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-accent);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.time-window-selector {
    margin: 2rem 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.time-window-selector label {
    font-weight: 600;
    font-size: 0.875rem;
}

.time-window-selector select {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.875rem;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(600px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.chart-container {
    background: var(--surface-1);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.recent-measurements {
    margin: 3rem 0;
}

.recent-measurements h3 {
    margin: 0 0 1rem;
}

/* Stats Fragment */
.stats-container {
    background: var(--surface-1);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 1rem;
    margin: 1rem 0;
}

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

.stats-header h4 {
    margin: 0;
    font-size: 0.875rem;
}

.stats-window {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

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

.stat-item .stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.stat-item .stat-value {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-accent);
}

/* Landing-page + about-page CSS moved to static/css/landing.css in Phase 3. */
/* Dashboard Sections */
.dashboard-section {
    margin-bottom: 2rem;
    background: var(--surface-1);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

/* .section-header / .section-actions removed — superseded by
 * components/page_header.html (use compact=True for in-page sub-headers). */

/* Probe Management */
.probe-management {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.masters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.master-card {
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 1rem;
    background: var(--surface-1);
}

.master-card h5 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.master-card p {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.deployments-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.deployment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: var(--surface-1);
}

.deployment-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.deployment-master {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.deployment-deployed {
    font-size: 0.75rem;
    color: var(--status-ok-fg);
    font-weight: 600;
}

.deployment-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Status Badges — legacy classes from before .status-pill existed. Now
 * consume the same tokens as .status-pill so they look identical in both
 * themes; the audit found these duplicated rules anyway (.status-ok ≡
 * .status-success, .status-warn ≡ .status-expired, etc.). New templates
 * should use components/status_pill.html instead; these stay until every
 * usage migrates. */
.status-badge {
    display: inline-block;
    padding: 3px var(--space-2);
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: var(--font-weight-semibold);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    border: 1px solid transparent;
}
.status-ok,
.status-success      { background: var(--status-ok-bg);      color: var(--status-ok-fg);      border-color: var(--status-ok-border); }
.status-warn,
.status-expired      { background: var(--status-warn-bg);    color: var(--status-warn-fg);    border-color: var(--status-warn-border); }
.status-critical,
.status-failed       { background: var(--status-crit-bg);    color: var(--status-crit-fg);    border-color: var(--status-crit-border); }
.status-inactive,
.status-pending,
.status-unknown      { background: var(--status-neutral-bg); color: var(--status-neutral-fg); border-color: var(--status-neutral-border); }

/* Empty States */
.empty-state {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 2rem;
}

.empty-state a {
    color: var(--accent-primary);
    text-decoration: none;
}

.empty-state a:hover {
    text-decoration: underline;
}

/* Deployment Detail */
.deployment-detail {
    max-width: 800px;
    margin: 0 auto;
}

.deployment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-subtle);
}

.deployment-header h2 {
    margin: 0;
    color: var(--text-primary);
}

.deployment-status {
    display: flex;
    gap: 0.5rem;
}

.deployment-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.info-section h3 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.5rem;
}

.info-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

.info-list dt {
    font-weight: 600;
    color: var(--text-primary);
}

.info-list dd {
    margin: 0;
    color: var(--text-secondary);
}

.feature-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.feature-list li {
    padding: 0.25rem 0;
    color: var(--text-primary);
}

.ip-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ip-list li {
    padding: 0.25rem 0;
}

.ip-list code {
    background: var(--surface-2);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.deployment-command {
    margin-bottom: 2rem;
}

.deployment-command h3 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
}

.command-box {
    position: relative;
    background: var(--text-primary);
    color: var(--surface-1);
    padding: 1rem;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    overflow-x: auto;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--text-primary);
    color: white;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

.copy-btn:hover {
    background: var(--text-secondary);
}

.deployment-log {
    margin-bottom: 2rem;
}

.deployment-log h3 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
}

.log-output {
    background: var(--surface-2);
    padding: 1rem;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    overflow-x: auto;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
}

.deployment-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-start;
}

/* Form Styles */
.form-container {
    max-width: 600px;
    margin: 0 auto;
}

.form-header {
    margin-bottom: 2rem;
    text-align: center;
}

.form-header h2 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.form-header p {
    margin: 0;
    color: var(--text-secondary);
}

.form-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: var(--surface-1);
}

.form-section h3 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-default);
    border-radius: 4px;
    font-size: 0.875rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-focus-ring);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check-input {
    width: auto;
}

.form-check-label {
    margin-bottom: 0;
    font-weight: normal;
}

.form-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.form-errors {
    margin-top: 0.25rem;
    color: var(--status-crit-fg);
    font-size: 0.875rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-start;
    margin-top: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .target-detail-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .target-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .hero-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .hero-actions .btn {
        width: 200px;
    }
    
    .probe-management {
        grid-template-columns: 1fr;
    }
    
    .deployment-info {
        grid-template-columns: 1fr;
    }
    
    .deployment-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
}

/* Dashboard stat-cards banner (HTMX-fetched every 60s). Reuses the existing
   .stat-card / .stat-value / .stat-label rules defined above for individual
   cards; this wrapper handles layout. */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card--alert {
    border-color: var(--color-crit-text);
    background: var(--color-crit);
}
.stat-card--alert .stat-value { color: var(--color-crit-text); }
.stat-change { font-size: 0.75rem; margin-top: 0.25rem; }
.stat-change.negative { color: var(--color-crit-text); }
.stat-change.positive { color: var(--color-ok-text); }

/* Probe-task / probetask detail page — stdout/stderr blocks. */
.command-block {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
}
.command-block--error {
    background: var(--color-crit);
    color: var(--color-crit-text);
    border-color: var(--color-crit-text);
}

/* Read-only attribute layout used on probe/probetask detail pages. */
.info-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.25rem;
    margin: 1rem 0;
}
.info-list dt {
    font-weight: 600;
    color: var(--color-off-text);
}
.info-list dd { margin: 0; }
