/* Panic Room - UI styles. Apple-inspired, minimal, premium. */

:root {
    --bg:        #F5F5F7;
    --surface:   #FFFFFF;
    --text:      #1D1D1F;
    --muted:     #86868B;
    --line:      #E5E5EA;
    --green:     #34C759;
    --red:       #FF3B30;
    --blue:      #0071E3;
    --amber:     #FF9F0A;
    --radius:    14px;
    --radius-sm: 10px;
    --shadow:    0 1px 2px rgba(0,0,0,0.04), 0 6px 24px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
                 Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
small { font-size: .85em; }
.muted { color: var(--muted); }
.small { font-size: .9em; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }

/* Topbar */
.topbar {
    background: rgba(255,255,255,0.85);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
    max-width: 1240px; margin: 0 auto; padding: 12px 24px;
    display: flex; align-items: center; gap: 16px;
}
.brand {
    color: var(--text); font-weight: 600;
    display: inline-flex; align-items: center; gap: 10px;
    font-size: 1.05rem;
}
.brand:hover { text-decoration: none; }
.brand-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 0 3px rgba(255,59,48,.18);
}
.brand-dot--lg { width: 14px; height: 14px; }
.nav { display: flex; gap: 18px; margin-left: 24px; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--text); font-weight: 500; font-size: .95rem; }
.nav a:hover { color: var(--blue); text-decoration: none; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.user-name { font-weight: 500; }
.user-role { color: var(--muted); font-size: .85rem; }
.link-button {
    background: none; border: none; padding: 0; cursor: pointer;
    color: var(--blue); font: inherit;
}
.link-button:hover { text-decoration: underline; }
.link-button.danger { color: var(--red); }

/* Layout */
.container { max-width: 1240px; margin: 0 auto; padding: 32px 24px; flex: 1; }
.footer { text-align: center; color: var(--muted); padding: 24px; border-top: 1px solid var(--line); background: #fff; }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: flex-end;
               gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header h1 { font-size: 1.8rem; font-weight: 600; margin: 0; letter-spacing: -.02em; }
.page-header p { margin: 4px 0 0; }
.h-sm { font-size: 1.1rem; font-weight: 600; margin: 16px 0 8px; }

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-padded { padding: 24px; }
.card-danger { border-left: 4px solid var(--red); }

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

/* Site card */
.site-card { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.site-card.state-red  { border-top: 3px solid var(--red); }
.site-card.state-green { border-top: 3px solid var(--green); }
.site-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.site-name { margin: 0; font-size: 1.15rem; font-weight: 600; letter-spacing: -.01em; }
.site-desc { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }
.site-status { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.led { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.led-green { background: var(--green); box-shadow: 0 0 0 4px rgba(52,199,89,.18); }
.led-red   { background: var(--red);   box-shadow: 0 0 0 4px rgba(255,59,48,.18); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(255,59,48,.18); }
    50%      { box-shadow: 0 0 0 8px rgba(255,59,48,.10); }
}
.site-meta {
    margin: 0; padding: 12px; background: var(--bg); border-radius: var(--radius-sm);
    display: grid; grid-template-columns: 1fr; gap: 6px; font-size: .9rem;
}
.site-meta > div { display: flex; justify-content: space-between; gap: 12px; }
.site-meta dt { color: var(--muted); margin: 0; }
.site-meta dd { margin: 0; text-align: right; word-break: break-word; max-width: 65%; }
.site-actions { margin-top: auto; }

/* Badges */
.badge {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    font-size: .78rem; font-weight: 500; letter-spacing: .02em;
    background: var(--bg); color: var(--muted); text-transform: capitalize;
}
.env-production  { background: rgba(255,59,48,.12);  color: #B00020; }
.env-staging     { background: rgba(255,159,10,.15); color: #8A4B00; }
.env-development { background: rgba(0,113,227,.12);  color: #034EA2; }
.role-admin    { background: rgba(255,59,48,.12);  color: #B00020; }
.role-operator { background: rgba(0,113,227,.12);  color: #034EA2; }
.role-viewer   { background: rgba(134,134,139,.18); color: #44464A; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; padding: 11px 20px; border-radius: 999px;
    border: 1px solid transparent; cursor: pointer; font-weight: 500;
    font-size: .95rem; text-decoration: none; transition: filter .15s, transform .05s;
}
.btn:hover { text-decoration: none; filter: brightness(.95); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--blue);  color: #fff; }
.btn-danger  { background: var(--red);   color: #fff; font-weight: 600; }
.btn-success { background: var(--green); color: #fff; font-weight: 600; }
.btn-ghost   { background: transparent; color: var(--text); border-color: var(--line); }
.btn-block   { width: 100%; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: .88rem; font-weight: 500; color: var(--text); }
.field input, .field select, .field textarea {
    width: 100%; padding: 12px 14px; border: 1px solid var(--line);
    border-radius: var(--radius-sm); font: inherit; background: #fff;
    color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(0,113,227,.15);
}
.field-check { flex-direction: row; align-items: center; gap: 10px; }
.field-check input { width: auto; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 4px; flex-wrap: wrap; }
.input-otp {
    text-align: center; font-size: 1.4rem; letter-spacing: .4em;
    font-variant-numeric: tabular-nums;
}

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 14px 16px; text-align: left; border-top: 1px solid var(--line); vertical-align: top; }
.table th { background: var(--bg); font-size: .85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-top: none; }
.table tbody tr:hover { background: rgba(0,113,227,.03); }
.td-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.td-actions form { display: inline; }

/* Alerts */
.alert { padding: 14px 18px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: .95rem; }
.alert-success { background: rgba(52,199,89,.12);  color: #1F6F36; border: 1px solid rgba(52,199,89,.25); }
.alert-error   { background: rgba(255,59,48,.10);  color: #8B0008; border: 1px solid rgba(255,59,48,.22); }
.bullets { margin: 0; padding-left: 18px; }

/* Auth shell */
.auth-shell { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 24px 0; }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px 32px; }
.auth-card-wide { max-width: 560px; }
.auth-header { text-align: center; margin-bottom: 28px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.auth-title { font-size: 1.6rem; font-weight: 600; margin: 4px 0 0; letter-spacing: -.02em; }
.auth-subtitle { color: var(--muted); margin: 0; }

/* TOTP setup */
.steps { padding-left: 22px; display: flex; flex-direction: column; gap: 22px; }
.steps li { padding-left: 8px; }
.qr-block { margin-top: 12px; display: flex; justify-content: center; padding: 18px; background: #fff; border-radius: var(--radius-sm); }
.qr-block img { display: block; max-width: 260px; height: auto; image-rendering: pixelated; }
.secret-block { margin: 8px 0 4px; }
.secret-code {
    display: inline-block; padding: 12px 16px; background: var(--bg);
    border-radius: var(--radius-sm); letter-spacing: .12em;
    font-size: 1.05rem; user-select: all;
}

/* Error pages */
.error-shell { text-align: center; padding: 80px 24px; max-width: 520px; margin: 0 auto; }
.error-shell h1 { font-size: 4rem; margin: 0; letter-spacing: -.04em; }
.error-detail { background: var(--bg); padding: 16px; border-radius: var(--radius-sm); text-align: left; overflow: auto; }

/* Responsive */
@media (max-width: 720px) {
    .container { padding: 20px 16px; }
    .topbar-inner { flex-wrap: wrap; padding: 12px 16px; }
    .nav { margin-left: 0; order: 3; width: 100%; gap: 14px; overflow-x: auto; }
    .topbar-user { margin-left: auto; }
    .page-header h1 { font-size: 1.45rem; }
    .grid { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
    .btn { padding: 13px 20px; }
    .site-meta dd { max-width: 60%; font-size: .88rem; }
}

