/* retoor <retoor@molodetz.nl> */

.services-page {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-2xl) var(--space-lg);
}

.services-page h1 {
    font-size: 1.5rem;
    margin-bottom: var(--space-xl);
    color: var(--text-primary);
}

.services-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.service-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-lg);
}

.service-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.service-name {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--text-primary);
    text-transform: capitalize;
}

.service-status {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.125rem var(--space-sm);
    border-radius: 10px;
    text-transform: uppercase;
}

.service-status.running {
    background: var(--success);
    color: var(--white);
}

.service-status.stopped {
    background: var(--danger);
    color: var(--white);
}

.service-status.stalled {
    background: var(--warning);
    color: var(--white);
}

.service-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.service-btn {
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.25rem var(--space-md);
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
}

.service-btn:hover:not(:disabled) {
    border-color: var(--accent);
}

.service-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.service-config {
    border-top: 1px solid var(--border);
    margin-bottom: var(--space-md);
    padding-top: var(--space-md);
}

.config-heading {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.config-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.config-status {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.field-error {
    display: block;
    color: var(--danger);
    font-size: 0.75rem;
    margin-top: 0.125rem;
}

.field-error:empty {
    display: none;
}

.service-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.service-metrics:empty {
    display: none;
}

.service-metrics {
    margin-bottom: var(--space-md);
}

.metric-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.metric-card {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: var(--space-sm) 0.625rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
}

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

.metric-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.metric-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.metric-table th,
.metric-table td {
    text-align: left;
    padding: 0.25rem var(--space-sm);
    border-bottom: 1px solid var(--border);
}

.metric-table th {
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.5px;
}

.metric-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--accent);
    text-decoration: none;
}

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

.meta-item {
    white-space: nowrap;
}

.service-log {
    background: var(--bg-input);
    border-radius: 6px;
    padding: var(--space-sm);
}

.log-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.log-output {
    font-family: "JetBrains Mono", "Fira Code", monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 300px;
    overflow-y: auto;
    margin: 0;
}

.no-services {
    color: var(--text-secondary);
    text-align: center;
    padding: var(--space-2xl) 0;
}

@media (max-width: 480px) {
    .services-page {
        padding: var(--space-lg) var(--space-sm);
    }

    .service-header {
        flex-wrap: wrap;
    }

    .service-meta {
        flex-direction: column;
        gap: 0.25rem;
    }

    .meta-item {
        white-space: normal;
    }
}

/* ---- Services index (table) ---- */
.services-index .service-row-name {
    font-weight: 600;
    color: var(--text-primary);
}

.services-index .service-row-name:hover {
    color: var(--accent);
}

.service-row-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
    max-width: 48ch;
}

/* ---- Service detail ---- */
.service-back {
    display: inline-block;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.service-detail-head {
    margin-bottom: 1rem;
}

.service-detail-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.service-detail-title h2 {
    margin: 0;
}

.service-detail-desc {
    color: var(--text-secondary);
    margin: 0.5rem 0 0.75rem;
    max-width: 70ch;
}

.service-detail-details {
    margin: 0 0 0.75rem;
    max-width: 80ch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    padding: 0.5rem 0.75rem;
}

.service-detail-details > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.service-detail-details-body {
    white-space: pre-line;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    line-height: 1.5;
    margin-top: 0.5rem;
}

/* ---- Tabs ---- */
.svc-tabbar {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.svc-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: var(--space-sm) 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
}

.svc-tab:hover {
    color: var(--text-primary);
}

.svc-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.svc-tabpane {
    display: none;
}

.svc-tabpane.active {
    display: block;
}

/* ---- Overview meta grid ---- */
.svc-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.625rem;
    margin-bottom: 1rem;
}

.svc-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: var(--space-sm) 0.625rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
}

.svc-meta-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.svc-meta-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ---- Config sections ---- */
.config-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.config-section legend {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 0 0.5rem;
}

.service-field-input {
    max-width: 160px;
}
