/* ============================================
   DC Admin — Admin Panel Styles
   Extends landing.css design system (zinc palette)
   ============================================ */

/* === Admin Header === */
.admin-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: hsl(var(--background) / 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid hsl(var(--border));
    box-shadow: var(--shadow-sm);
}

.admin-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 4rem;
}

.admin-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.admin-nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--muted-fg));
    transition: color 0.2s;
}

.admin-nav-link:hover {
    color: hsl(var(--foreground));
}

/* === Admin Content === */
.admin-content {
    padding-top: 6rem;
    padding-bottom: 3rem;
    min-height: 100vh;
}

.admin-content h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

/* === Status Badge === */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

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

.status-ok {
    color: hsl(142 71% 35%);
    background: hsl(142 71% 45% / 0.1);
}

.status-ok .status-dot {
    background: hsl(142 71% 45%);
}

.status-error {
    color: hsl(0 84% 50%);
    background: hsl(0 84% 60% / 0.1);
}

.status-error .status-dot {
    background: hsl(0 84% 60%);
}

.status-unavailable {
    color: hsl(var(--muted-fg));
    background: hsl(var(--muted) / 0.5);
}

.status-unavailable .status-dot {
    background: hsl(var(--muted-fg));
}

/* === Admin Card (inbound section) === */
.admin-card {
    margin-bottom: 1.5rem;
}

.admin-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.admin-card-header h2 {
    font-size: 1.25rem;
}

.text-muted {
    font-weight: 400;
    color: hsl(var(--muted-fg));
    font-size: 0.875rem;
}

/* === Users Table === */
.users-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.users-table thead th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: hsl(var(--muted-fg));
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid hsl(var(--border));
}

.users-table tbody td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid hsl(var(--border) / 0.5);
    vertical-align: middle;
}

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

.users-table tbody tr:hover {
    background: hsl(var(--muted) / 0.3);
}

.col-actions {
    width: 140px;
    text-align: right;
    white-space: nowrap;
}

/* Table input (inline editing) */
.table-input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: hsl(var(--foreground));
    width: 100%;
    max-width: 240px;
    transition: border-color 0.2s, background 0.2s;
}

.table-input:hover {
    border-color: hsl(var(--border));
}

.table-input:focus {
    outline: none;
    border-color: hsl(var(--ring));
    background: hsl(var(--background));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.1);
}

.table-input-error,
.table-input-error:hover,
.table-input-error:focus {
    border-color: hsl(0 84% 60%);
    background: hsl(0 84% 60% / 0.08);
    box-shadow: 0 0 0 2px hsl(0 84% 60% / 0.15);
}

/* Password cell */
.password-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.password-text {
    font-family: "SF Mono", "Cascadia Code", "Fira Code", monospace;
    font-size: 0.8125rem;
    background: hsl(var(--secondary));
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius);
    word-break: break-all;
}

.password-masked {
    color: hsl(var(--muted-fg));
    font-size: 0.875rem;
    letter-spacing: 0.05em;
}

/* Icon button (toggle password) */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius);
    color: hsl(var(--muted-fg));
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.btn-icon:hover {
    color: hsl(var(--foreground));
    background: hsl(var(--muted) / 0.5);
}

/* Add user button */
.add-user-btn {
    margin-top: 0.25rem;
}

/* === Danger Button === */
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: hsl(0 84% 60%);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-danger:hover {
    opacity: 0.9;
}

/* === Save Bar === */
.save-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid hsl(var(--border));
}

.save-hint {
    font-size: 0.875rem;
    color: hsl(35 90% 50%);
}

.save-success {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(142 71% 35%);
}

.save-error {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(0 84% 50%);
}

/* === Login Page === */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsl(var(--secondary));
    padding: 1rem;
}

.login-page .login-card {
    max-width: 400px;
    width: 100%;
}

.login-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.login-header h2 {
    font-size: 1.5rem;
    margin: 0;
}

.login-error {
    background: hsl(0 84% 60% / 0.1);
    color: hsl(0 84% 50%);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.625rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid hsl(0 84% 60% / 0.2);
}

.loading-text {
    color: hsl(var(--muted-fg));
}

/* disabled state for buttons */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Monitoring Panel === */
.monitoring-card {
    margin-bottom: 2rem;
}

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

.monitoring-header h2 {
    font-size: 1.25rem;
    margin: 0;
}

.monitoring-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0.75rem;
}

.monitoring-table thead th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: hsl(var(--muted-fg));
    padding: 0.375rem 0.75rem;
    border-bottom: 1px solid hsl(var(--border));
}

.monitoring-table tbody td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid hsl(var(--border) / 0.5);
    font-size: 0.875rem;
    vertical-align: middle;
}

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

.monitoring-table tbody tr:hover {
    background: hsl(var(--muted) / 0.3);
}

.traffic-value {
    font-family: "SF Mono", "Cascadia Code", "Fira Code", monospace;
    font-size: 0.8125rem;
    white-space: nowrap;
}

.dot-active {
    background: hsl(142 71% 45%);
}

.dot-inactive {
    background: hsl(var(--muted-fg) / 0.4);
}

.monitoring-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.5rem;
    font-size: 0.8125rem;
}

.monitoring-footer .status-dot {
    display: inline-block;
    margin-right: 0.25rem;
    vertical-align: middle;
}

/* === Status diagram (top of monitoring page) === */
.status-diagram {
    background: hsl(var(--muted) / 0.2);
    border-radius: var(--radius);
    padding: 0.75rem 1rem 0.5rem;
    margin-bottom: 1.25rem;
}

.status-svg {
    width: 100%;
    height: 220px;
    display: block;
}

.diagram-label {
    font-size: 11px;
    fill: hsl(var(--foreground));
}

.diagram-server-label {
    font-weight: 600;
    font-size: 12px;
}

.diagram-sublabel {
    font-size: 10px;
    fill: hsl(var(--muted-fg));
}

.diagram-caption {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    fill: hsl(var(--muted-fg));
}

.status-svg line {
    transition: stroke 0.4s ease, opacity 0.4s ease;
}

.status-svg circle,
.status-svg rect {
    transition: fill 0.4s ease, stroke 0.4s ease;
}

.status-diagram-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.25rem 0.25rem 0;
    font-size: 0.75rem;
    color: hsl(var(--muted-fg));
}

.status-diagram-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

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

.status-diagram-dot.dot-ok    { background: hsl(142 71% 45%); }
.status-diagram-dot.dot-fail  { background: hsl(0 84% 60%); }
.status-diagram-dot.dot-stale { background: hsl(240 3.8% 70%); }

/* === Monitoring page (charts) === */
.monitoring-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.range-switch {
    display: inline-flex;
    gap: 0.25rem;
}

.range-switch .btn-outline.is-active {
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    border-color: hsl(var(--foreground));
}

.chart-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: hsl(var(--muted-fg));
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1.5rem 0 0.5rem;
}

.chart-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.chart-section-header .chart-section-title {
    margin-bottom: 0;
}

.chart-subtitle {
    font-size: 1rem;
    margin: 0 0 0.5rem;
}

.chart-container {
    margin-bottom: 1rem;
}

.availability-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.375rem;
}

.availability-label {
    font-size: 0.8125rem;
    color: hsl(var(--muted-fg));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.availability-strip {
    width: 100%;
    height: 40px;
    background: hsl(var(--muted) / 0.3);
    /* border-radius: var(--radius); */
    overflow: hidden;
}

.chart-label {
    font-size: 10px;
    fill: hsl(var(--muted-fg));
}

.latency-chart-wrapper {
    background: hsl(var(--muted) / 0.2);
    border-radius: var(--radius);
    padding: 0.5rem;
}

.latency-chart {
    width: 100%;
    height: 220px;
    display: block;
}

.chart-grid {
    stroke: hsl(var(--border));
    stroke-width: 0.5;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.5rem 0.25rem 0;
    font-size: 0.8125rem;
    color: hsl(var(--muted-fg));
}

.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.chart-legend-swatch {
    display: inline-block;
    width: 12px;
    height: 3px;
    border-radius: 2px;
}

.chart-legend-swatch-svg {
    display: inline-block;
    vertical-align: middle;
}

.chart-tooltip {
    position: fixed;
    padding: 0.25rem 0.5rem;
    background: hsl(var(--card));
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    font-size: 0.75rem;
    font-family: "SF Mono", "Cascadia Code", "Fira Code", monospace;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
}

[data-tooltip] {
    cursor: crosshair;
}

@media (max-width: 768px) {
    .availability-row {
        grid-template-columns: 100px 1fr;
        gap: 0.5rem;
    }
}

/* === Responsive === */
@media (max-width: 768px) {
    .admin-content h1 {
        font-size: 1.5rem;
    }

    .admin-card-header {
        flex-direction: column;
        gap: 0.25rem;
    }

    .users-table thead {
        display: none;
    }

    .users-table tbody tr {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem 0;
        border-bottom: 1px solid hsl(var(--border));
    }

    .users-table tbody td {
        border: none;
        padding: 0;
    }

    .users-table tbody td:first-child {
        flex: 1 1 100%;
    }

    .password-cell {
        flex: 1;
    }

    .col-actions {
        width: auto;
        text-align: left;
    }

    .save-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .monitoring-table thead {
        display: none;
    }

    .monitoring-table tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.25rem 0.5rem;
        padding: 0.625rem 0;
        border-bottom: 1px solid hsl(var(--border));
    }

    .monitoring-table tbody td {
        border: none;
        padding: 0;
    }

    .monitoring-table tbody td:first-child {
        grid-column: 1 / -1;
        font-weight: 500;
    }

    .monitoring-footer {
        flex-direction: column;
        gap: 0.25rem;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .admin-header-inner {
        height: 3.5rem;
    }

    .admin-content {
        padding-top: 5rem;
    }

    .admin-nav {
        gap: 0.75rem;
    }

    .table-input {
        max-width: none;
    }
}
