/* =============================================================================
   CNNECT Production Dashboard — style.css
   Copied from staging_dashboard/style.css (same visual system) — kept in sync
   manually, not shared via include, since each dashboard vhost is self-contained.
   Aesthetic: Obsidian Control Room
   Fonts: Bebas Neue (headings) · Barlow (UI) · DM Mono (technical/code)
============================================================================= */

/* ── Custom properties ───────────────────────────────────────────────────── */
:root {
    /* Backgrounds */
    --bg-base:       #07090f;
    --bg-surface:    #0c1220;
    --bg-card:       #101828;
    --bg-card-hover: #142034;
    --bg-modal:      #0c1728;

    /* Borders */
    --border:        rgba(255, 255, 255, 0.07);
    --border-hover:  rgba(255, 255, 255, 0.13);
    --border-accent: rgba(0, 217, 255, 0.25);

    /* Text */
    --text-primary:   #dde6f0;
    --text-secondary: #6e87a0;
    --text-muted:     #3d5268;

    /* Accent */
    --accent:      #00d9ff;
    --accent-dim:  rgba(0, 217, 255, 0.08);
    --accent-glow: rgba(0, 217, 255, 0.25);

    /* Status */
    --live:            #00d98a;
    --live-bg:         rgba(0, 217, 138, 0.1);
    --live-border:     rgba(0, 217, 138, 0.25);
    --failed:          #ff4757;
    --failed-bg:       rgba(255, 71, 87, 0.1);
    --failed-border:   rgba(255, 71, 87, 0.25);
    --retired:         #3d5268;
    --retired-bg:      rgba(61, 82, 104, 0.15);
    --retired-border:  rgba(61, 82, 104, 0.3);
    --provisioning:    #ffa31a;
    --retiring:        #ffa31a;

    /* Type */
    --font-head: 'Bebas Neue', 'Arial Narrow', sans-serif;
    --font-ui:   'Barlow', system-ui, sans-serif;
    --font-mono: 'DM Mono', 'Courier New', monospace;

    /* Layout */
    --header-h:   64px;
    --max-w:      1440px;
    --r:          6px;
    --r-lg:       10px;
}

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

html { font-size: 15px; }

body {
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-ui);
    line-height: 1.65;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font-ui); }
strong { font-weight: 600; }

/* ── Site Header ─────────────────────────────────────────────────────────── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 200;
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 36px;
    gap: 24px;
    background: rgba(7, 9, 15, 0.88);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* ── Logo area ───────────────────────────────────────────────────────────── */
.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 176px;
}

.logo-img {
    width: 24px;
}

.brand-name {
    display: block;
    font-family: var(--font-head);
    font-size: 22px;
    letter-spacing: 0.08em;
    line-height: 1;
    color: var(--text-primary);
}

.brand-sub {
    display: block;
    font-size: 9.5px;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 1px;
}

.back-link {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    transition: color 0.15s;
}
.back-link:hover { color: var(--accent); }

/* ── Tab navigation ──────────────────────────────────────────────────────── */
.tab-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    justify-content: center;
}

.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 22px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.tab.active {
    color: var(--accent);
    background: var(--accent-dim);
    border-color: var(--border-accent);
}

.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}

.tab.active .tab-badge,
.tab-badge.live    { background: var(--live-bg);    color: var(--live);   }
.tab-badge.failed  { background: var(--failed-bg);  color: var(--failed); }
.tab-badge.retired { background: var(--retired-bg); color: var(--retired);}

/* ── Header right ────────────────────────────────────────────────────────── */
.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 176px;
    justify-content: flex-end;
}

.current-user {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}

.btn-logout {
    padding: 6px 14px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--r);
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-logout:hover {
    color: var(--failed);
    border-color: var(--failed-border);
    background: var(--failed-bg);
}

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 44px 36px;
}

/* ── Tab panels ──────────────────────────────────────────────────────────── */
.tab-panel         { display: none; animation: fade-in 0.18s ease; }
.tab-panel.active  { display: block; }

@keyframes fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Instance grid ───────────────────────────────────────────────────────── */
.instance-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* ── Instance card ───────────────────────────────────────────────────────── */
.instance-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 22px;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
    text-decoration: none;
    color: inherit;
}

/* Cyan left-rail reveal on hover */
.instance-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: linear-gradient(180deg, var(--accent) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: var(--r-lg) 0 0 var(--r-lg);
}

.instance-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--border-accent);
}
.instance-card:hover::before { opacity: 1; }

/* Card internals */
.card-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.repo-id {
    font-family: var(--font-mono);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-url {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--accent);
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 18px;
}

.card-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}

.meta-item { display: flex; flex-direction: column; gap: 2px; }

.meta-label {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.meta-val {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.meta-val.mono {
    font-family: var(--font-mono);
    font-size: 12px;
}

/* ── Status dots ─────────────────────────────────────────────────────────── */
.status-dot {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-dot.live {
    background: var(--live);
    box-shadow: 0 0 0 0 var(--live-bg);
    animation: pulse-live 2.4s ease-in-out infinite;
}
.status-dot.provisioning { background: var(--provisioning); box-shadow: 0 0 6px rgba(255, 163, 26, 0.4); }
.status-dot.failed       { background: var(--failed);       box-shadow: 0 0 8px var(--failed-bg); }
.status-dot.retiring     { background: var(--retiring); }
.status-dot.retired      { background: var(--retired); }

@keyframes pulse-live {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 217, 138, 0.5); }
    50%       { box-shadow: 0 0 0 5px rgba(0, 217, 138, 0); }
}

/* ── Status badges ───────────────────────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 11px;
    border-radius: 20px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.status-badge.live         { background: var(--live-bg);    color: var(--live);   border: 1px solid var(--live-border);    }
.status-badge.provisioning { background: rgba(255,163,26,.1); color: var(--provisioning); border: 1px solid rgba(255,163,26,.25); }
.status-badge.failed       { background: var(--failed-bg);  color: var(--failed); border: 1px solid var(--failed-border);  }
.status-badge.retiring     { background: rgba(255,163,26,.1); color: var(--retiring); border: 1px solid rgba(255,163,26,.25); }
.status-badge.retired      { background: var(--retired-bg); color: var(--retired); border: 1px solid var(--retired-border); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 100px 24px;
    text-align: center;
    color: var(--text-muted);
}
.empty-icon {
    font-size: 52px;
    opacity: 0.18;
    margin-bottom: 18px;
    line-height: 1;
}
.empty-state p {
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* ── Instance detail page ────────────────────────────────────────────────── */
.instance-detail { max-width: 960px; margin: 0 auto; }

.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.detail-id-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.detail-id {
    font-family: var(--font-head);
    font-size: 44px;
    letter-spacing: 0.04em;
    line-height: 1;
    color: var(--text-primary);
}

.detail-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding-top: 4px;
}

/* Detail grid — 2-col with a full-span row for the URL */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 22px 24px;
}
.detail-card.full-span { grid-column: 1 / -1; }

.detail-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.detail-value {
    font-size: 15px;
    color: var(--text-primary);
    word-break: break-all;
}

.detail-link {
    color: var(--accent);
    transition: opacity 0.15s;
}
.detail-link:hover { opacity: 0.75; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: var(--accent);
    color: #07090f;
    border: none;
    border-radius: var(--r);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
    text-decoration: none;
}
.btn-primary:hover {
    background: #33e5ff;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}
.btn-primary.full-width {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    padding: 10px 22px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-hover);
    border-radius: var(--r);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    text-decoration: none;
}
.btn-secondary:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.18);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    padding: 10px 22px;
    background: var(--failed-bg);
    color: var(--failed);
    border: 1px solid var(--failed-border);
    border-radius: var(--r);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}
.btn-danger:hover {
    background: rgba(255, 71, 87, 0.18);
    box-shadow: 0 6px 20px rgba(255, 71, 87, 0.2);
}

/* ── Retire modal ────────────────────────────────────────────────────────── */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 9, 15, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 500;
    align-items: center;
    justify-content: center;
}
.modal-backdrop.open { display: flex; animation: backdrop-in 0.18s ease; }

@keyframes backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal {
    background: var(--bg-modal);
    border: 1px solid rgba(255, 71, 87, 0.2);
    border-radius: var(--r-lg);
    padding: 36px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border);
    animation: modal-in 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.modal-title {
    font-family: var(--font-head);
    font-size: 30px;
    letter-spacing: 0.04em;
    color: var(--failed);
    margin-bottom: 14px;
}

.modal-body {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 14px;
    line-height: 1.55;
}

.modal-warning {
    background: rgba(255, 71, 87, 0.06);
    border: 1px solid var(--failed-border);
    border-radius: var(--r);
    padding: 13px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 28px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.modal-actions form { margin: 0; }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse 100% 70% at 50% -10%, rgba(0, 217, 255, 0.05) 0%, transparent 60%),
        var(--bg-base);
}

.login-wrap {
    width: 100%;
    max-width: 420px;
    padding: 24px;
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 44px 40px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 38px;
}

.login-brand {
    display: block;
    font-family: var(--font-head);
    font-size: 30px;
    letter-spacing: 0.1em;
    line-height: 1;
    color: var(--text-primary);
}

.login-sub {
    display: block;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 3px;
}

.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    background: var(--bg-card);
    border: 1px solid var(--border-hover);
    border-radius: var(--r);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input::placeholder { color: var(--text-muted); }
.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.alert {
    padding: 12px 16px;
    border-radius: var(--r);
    font-size: 13px;
    margin-bottom: 22px;
    line-height: 1.45;
}
.alert-error {
    background: var(--failed-bg);
    border: 1px solid var(--failed-border);
    color: var(--failed);
}

.login-note {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 22px;
    letter-spacing: 0.02em;
}

/* ── Deployment history table (production dashboard only) ──────────────────── */
.history-section { margin-top: 40px; }

.history-title {
    font-family: var(--font-head);
    font-size: 22px;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.history-table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.history-table th {
    text-align: left;
    padding: 12px 18px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.history-table td {
    padding: 12px 18px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

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

.history-table .commit-cell {
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-table tr.row-failed td { color: var(--text-primary); }

.history-table tr.row-error-detail td {
    padding-top: 0;
    color: var(--failed);
    font-family: var(--font-mono);
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.mono { font-family: var(--font-mono); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .instance-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .site-header    { padding: 0 20px; gap: 16px; }
    .header-logo .brand-name { font-size: 18px; }
    .tab            { padding: 6px 14px; font-size: 12px; }
    .main-content   { padding: 28px 20px; }
    .instance-grid  { grid-template-columns: 1fr; }
    .detail-grid    { grid-template-columns: 1fr; }
    .detail-card.full-span { grid-column: 1; }
    .detail-header  { flex-direction: column; }
    .detail-id      { font-size: 32px; }
    .login-card     { padding: 32px 28px; }
    .current-user   { display: none; }
    .history-table  { font-size: 12px; }
    .history-table th,
    .history-table td { padding: 10px 12px; }
}

@media (max-width: 480px) {
    .tab-badge      { display: none; }
    .header-right   { gap: 10px; }
}
