/* Re-themed legacy styles.
   Existing pages still use the mono-* class names from the original "ops terminal"
   theme. This stylesheet re-maps those classes onto the new design tokens so
   inner panels and tables inherit the new look without per-component changes. */

/* Loading spinner animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: 24rem;
}

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

.toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 5px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.25s ease-out;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}
.toast-content { display: flex; align-items: center; gap: 0.6rem; flex: 1; }
.toast-icon { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }
.toast-message { flex: 1; font-size: 13px; line-height: 1.35; }
.toast-close {
    flex-shrink: 0;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit;
}
.toast-close:hover { background-color: color-mix(in oklch, currentColor 10%, transparent); }

.toast-success { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in oklch, var(--ok) 25%, transparent); }
.toast-error   { background: var(--err-bg); color: var(--err); border-color: color-mix(in oklch, var(--err) 25%, transparent); }
.toast-info    { background: var(--info-bg); color: var(--info); border-color: color-mix(in oklch, var(--info) 25%, transparent); }

/* Modal (legacy) */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(20, 20, 15, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    padding: 1rem;
    overflow-y: auto;
}
.dark .modal-backdrop { background-color: rgba(0, 0, 0, 0.55); }

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 100%;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    color: var(--text);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 12px;
    border-bottom: 1px solid var(--border-faint);
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
}

.modal-close-button {
    color: var(--text-muted);
    background: transparent;
    border: none;
    padding: 0.4rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close-button:hover { background-color: var(--hover); color: var(--text); }
.modal-body { padding: 18px 22px; overflow-y: auto; flex: 1; }

/* Prose (markdown) */
.prose { color: var(--text); line-height: 1.7; }
.prose h1 { font-weight: 700; font-size: 1.8rem; margin: 0 0 1rem; color: var(--text); }
.prose h2 { font-weight: 600; font-size: 1.4rem; margin: 1.8rem 0 1rem; color: var(--text); }
.prose h3 { font-weight: 600; font-size: 1.15rem; margin: 1.4rem 0 .6rem; color: var(--text); }
.prose h4 { font-weight: 600; font-size: 1rem; margin: 1.2rem 0 .5rem; color: var(--text); }
.prose p { margin: .8rem 0; }
.prose ul, .prose ol { margin: .8rem 0; padding-left: 1.5rem; }
.prose li { margin: .3rem 0; }
.prose ul > li { list-style: disc; }
.prose ol > li { list-style: decimal; }
.prose code {
    color: var(--text);
    background-color: var(--surface-2);
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    font-size: 0.875em;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.prose pre {
    background-color: var(--surface-2);
    color: var(--text);
    overflow-x: auto;
    font-size: 0.875em;
    margin: 1rem 0;
    border-radius: 5px;
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--border-faint);
}
.prose pre code { background: transparent; padding: 0; }
.prose strong { color: var(--text); font-weight: 600; }
.prose a { color: var(--accent); text-decoration: underline; }
.prose blockquote {
    border-left: 3px solid var(--border);
    color: var(--text-muted);
    margin: 1rem 0;
    padding-left: 1rem;
}
.prose hr { border: none; border-top: 1px solid var(--border-faint); margin: 1.6rem 0; }
.prose table { width: 100%; margin: 1.2rem 0; font-size: 0.9em; border-collapse: collapse; }
.prose thead { color: var(--text); font-weight: 600; border-bottom: 1px solid var(--border); }
.prose thead th { vertical-align: bottom; padding: .5rem .75rem .5rem 0; text-align: left; }
.prose tbody tr { border-bottom: 1px solid var(--border-faint); }
.prose tbody tr:last-child { border-bottom: 0; }
.prose tbody td { vertical-align: baseline; padding: .55rem .75rem .55rem 0; }

/* SVG Icon Masking */
.svg-mask {
    background-color: currentColor;
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
}

/* ===================================================================
   Re-theme of legacy mono-* utility classes to fit the new design.
   Pages still use these class names; this stylesheet redirects them
   to the new tokens so the UI is visually consistent.
   =================================================================== */

/* Sidebar / top-level shell (legacy mono-shell - mostly unused after redesign) */
.mono-app, .mono-shell { background: var(--bg); }

/* Notice / inline messages */
.mono-notice {
    border: 1px solid var(--border-faint);
    background: var(--surface-2);
    color: var(--text-muted);
    padding: 10px 14px;
    border-radius: 5px;
    font-size: 12.75px;
}
.mono-notice a { color: var(--accent); text-decoration: underline; }

.mono-inline-status {
    font-size: 12.5px;
    color: var(--text-muted);
}

/* Buttons */
.mono-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.14s, border 0.14s, transform 0.12s;
    line-height: 1.2;
    white-space: nowrap;
}
.mono-btn:hover { background: var(--hover); }
.mono-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.mono-btn-sm { padding: 5px 10px; font-size: 12px; }
.mono-btn-md { padding: 7px 12px; font-size: 12.75px; }
.mono-btn-lg { padding: 9px 14px; font-size: 13.5px; }
.mono-btn-primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.mono-btn-primary:hover { filter: brightness(1.06); background: var(--accent); }
.mono-btn-secondary { /* default */ }
.mono-btn-danger { color: var(--err); border-color: color-mix(in oklch, var(--err) 30%, var(--border)); }
.mono-btn-danger:hover { background: var(--err-bg); }
.mono-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid color-mix(in oklch, currentColor 30%, transparent);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

/* Form fields */
.mono-label {
    display: block;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: none;
    letter-spacing: 0;
}
.mono-input,
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field input[type="number"],
.form-field input[type="url"],
.form-field input[type="search"],
.form-field input[type="tel"],
.form-field input[type="datetime-local"],
.form-field input[type="date"],
.form-field input[type="time"],
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 8px 11px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    transition: border 0.14s, box-shadow 0.14s;
}
.mono-input:focus,
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 16%, transparent);
}
.form-field textarea { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; min-height: 80px; }
.form-field { margin-bottom: 12px; }

/* Tabs */
.mono-tabbar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-faint);
    padding: 0 2px;
}
.mono-tabbar > * { display: flex; gap: 4px; flex-wrap: wrap; }
.mono-tab-button {
    cursor: pointer;
    padding: 9px 12px;
    font-size: 13.5px;
    color: var(--text-muted);
    background: transparent;
    border: none;
    position: relative;
    border-radius: 4px 4px 0 0;
}
.mono-tab-button:hover { color: var(--text); background: var(--surface-2); }
.mono-tab-button.active { color: var(--text); font-weight: 500; }
.mono-tab-button.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}
.mono-tab-panel { font-size: 13px; color: var(--text); }

/* Tables (legacy MonoTable). Make them look like .r-table. */
.mono-table-frame {
    border: 1px solid var(--border-faint);
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface);
}
/* Allow horizontal scrolling for wide tables — prevents clipping when the
   viewport is narrower than the table's natural width. */
.mono-table-frame:has(> .mono-table) { overflow-x: auto; }
.mono-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.mono-table thead th {
    text-align: left;
    font-weight: 500;
    color: var(--text-soft);
    font-size: 11.25px;
    padding: 9px 18px;
    border-bottom: 1px solid var(--border-faint);
    background: var(--surface-2);
    white-space: nowrap;
    text-transform: none;
    letter-spacing: 0;
}
.mono-table tbody td {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-faint);
    vertical-align: middle;
    color: var(--text);
}
.mono-table tbody tr:last-child td { border-bottom: none; }
.mono-table tbody tr.mono-row-interactive { cursor: pointer; transition: background 0.14s; }
.mono-table tbody tr.mono-row-interactive:hover td { background: var(--hover); }
.mono-table tbody tr.mono-row-active td { background: var(--surface-2); }
.mono-sort-button {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-soft);
    font: inherit;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.mono-sort-button:hover, .mono-sort-button.active { color: var(--text); }
.mono-table-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
}

/* Status badge / chip — re-theme legacy mono-status to look like .r-status */
.mono-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    border-radius: 4px;
    font-size: 11.75px;
    font-weight: 500;
    line-height: 1.45;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border-faint);
}
.mono-status-ok    { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.mono-status-warn  { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.mono-status-bad   { color: var(--err); background: var(--err-bg); border-color: transparent; }
.mono-status-muted { color: var(--text-soft); background: var(--surface-2); border-color: var(--border-faint); }

/* Status strip (rows of stats) */
.mono-status-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    border: 1px solid var(--border-faint);
    border-radius: 6px;
    padding: 14px 18px;
    background: var(--surface);
    margin-bottom: 16px;
}
.mono-status-strip > div { display: flex; flex-direction: column; gap: 4px; }
.mono-status-strip span:first-child {
    font-size: 11px;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
}
.mono-status-strip strong { font-size: 13.5px; font-weight: 500; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.mono-status-strip-normalcase strong { text-transform: none; }
.mono-status-card { border-left: 3px solid transparent; padding-left: 10px; }
.mono-status-card-ok    { border-left-color: var(--ok); }
.mono-status-card-warn  { border-left-color: var(--warn); }
.mono-status-card-bad   { border-left-color: var(--err); }
.mono-status-card-muted { border-left-color: var(--text-soft); }

.mono-active-deployment-card {
    background: var(--surface);
    border: 1px solid var(--border-faint) !important;
    border-radius: 6px;
    padding: 18px !important;
    cursor: pointer;
    transition: background 0.14s, border-color 0.14s;
}
.mono-active-deployment-card:hover { background: var(--surface-2); border-color: var(--border) !important; }
.mono-active-deployments-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 768px) { .mono-active-deployments-grid { grid-template-columns: 1fr 1fr; } }

.mono-active-deployment-card h5 { color: var(--text); font-size: 14px; font-weight: 600; margin: 0; }

/* Inline copy buttons */
.mono-copyable-value { display: inline-flex; align-items: center; gap: 6px; }
.mono-copy-button {
    appearance: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: var(--text-muted);
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.14s, background 0.14s, color 0.14s;
}
.mono-copyable-value:hover .mono-copy-button { opacity: 1; }
.mono-copy-button:hover { background: var(--hover); color: var(--text); }
.mono-copy-icon { width: 12px; height: 12px; display: inline-block; }
.mono-icon-button {
    appearance: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-muted);
    border-radius: 4px;
}
.mono-icon-button:hover { background: var(--hover); color: var(--text); }

.mono-nav-vsep { width: 1px; height: 14px; background: var(--border-faint); display: inline-block; }

/* Legacy "state" boxes */
.mono-state {
    text-align: center;
    padding: 28px;
    border: 1px dashed var(--border-strong);
    background: var(--surface-2);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 13px;
}
.mono-state p { margin: 0 0 12px; }
.mono-state-error { color: var(--err); border-color: color-mix(in oklch, var(--err) 30%, var(--border)); background: var(--err-bg); }

/* Legacy login wrap — still used as fallback */
.mono-login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--bg);
}
.mono-login-card {
    width: 380px;
    max-width: 100%;
    padding: 32px;
    border: 1px solid var(--border-faint);
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    color: var(--text);
}
.mono-login-logo {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    background: var(--accent);
    color: var(--accent-fg);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 22px;
    box-shadow: var(--shadow-sm);
}
.mono-login-title { font-size: 20px; font-weight: 600; color: var(--text); margin: 8px 0 4px; }
.mono-login-subtitle { font-size: 13.5px; color: var(--text-muted); margin: 0; }
.mono-login-button {
    width: 100%;
    padding: 10px 14px;
    margin-top: 14px;
    background: var(--accent);
    color: var(--accent-fg);
    border: none;
    border-radius: 4px;
    font-weight: 500;
    font-size: 13.5px;
    cursor: pointer;
    transition: filter 0.14s;
}
.mono-login-button:hover { filter: brightness(1.06); }

/* Shortcut hint */
.mono-shortcut-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    font-size: 11.5px;
    color: var(--text-soft);
    border-radius: 4px;
}
.mono-shortcut-hint code {
    font-family: 'JetBrains Mono', monospace;
    background: var(--surface-2);
    border: 1px solid var(--border-faint);
    border-radius: 3px;
    padding: 1px 5px;
    color: var(--text-muted);
    font-size: 11px;
}

/* Sticky header in tables */
.mono-sticky-table thead th { position: sticky; top: 0; z-index: 1; }
.mono-sticky-col { position: sticky; left: 0; background: var(--surface); }
.mono-table thead .mono-sticky-col { background: var(--surface-2); }
