/* ========================================
   SiteWatch — Clean Light Theme v2
   ======================================== */

:root {
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --bg: #f5f5f0;
    --bg-card: #ffffff;
    --bg-input: #fafaf8;
    --bg-hover: #f0f0eb;

    --text-primary: #1a1a2e;
    --text-secondary: #5a5a72;
    --text-muted: #9494a8;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: #eff4ff;

    --green: #16a34a;
    --green-soft: #f0fdf4;
    --green-bg: #dcfce7;
    --yellow: #d97706;
    --yellow-soft: #fffbeb;
    --yellow-bg: #fef3c7;
    --orange: #ea580c;
    --red: #dc2626;
    --red-soft: #fef2f2;
    --red-bg: #fee2e2;
    --purple: #7c3aed;
    --purple-soft: #f5f3ff;

    --border: #e5e5dd;
    --border-strong: #d0d0c8;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* ---- Navbar ---- */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 32px;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.3px;
}
.nav-links { display: flex; gap: 4px; }
.nav-links a, .nav-user {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 13.5px;
    transition: all 0.15s ease;
}
.nav-links a:hover, .nav-user:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-links a.active { background: var(--accent-soft); color: var(--accent); }
.nav-notif { position: relative; }
.notif-badge {
    position: absolute; top: 0; right: 2px;
    background: var(--red); color: #fff;
    font-size: 10px; font-weight: 700;
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
}
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav-user { display: flex; align-items: center; gap: 6px; }
.nav-logout {
    color: var(--text-muted); text-decoration: none;
    font-size: 13px; padding: 6px 10px;
    border-radius: var(--radius-sm); transition: all 0.15s ease;
}
.nav-logout:hover { color: var(--red); background: var(--red-soft); }

/* ---- Layout ---- */
.main-content { flex: 1; padding: 32px 0; }
.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.footer {
    padding: 24px 0; text-align: center;
    color: var(--text-muted); font-size: 12.5px;
    border-top: 1px solid var(--border);
}

/* ---- Flash ---- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 13.5px; font-weight: 500; }
.flash-success { background: var(--green-soft); color: var(--green); border: 1px solid #bbf7d0; }
.flash-error { background: var(--red-soft); color: var(--red); border: 1px solid #fecaca; }
.flash-warning { background: var(--yellow-soft); color: var(--yellow); border: 1px solid #fde68a; }

/* ---- Page Header ---- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.page-header p { color: var(--text-secondary); font-size: 14px; margin-top: 2px; }

/* ---- Cards ---- */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { font-size: 15px; font-weight: 600; }

/* ---- Stat Grid ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; letter-spacing: -1px; }
.stat-card.stat-healthy .stat-value { color: var(--green); }
.stat-card.stat-issues .stat-value { color: var(--red); }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; letter-spacing: 0.2px; }
.badge-healthy { background: var(--green-soft); color: var(--green); }
.badge-warning { background: var(--yellow-soft); color: var(--yellow); }
.badge-critical { background: var(--red-soft); color: var(--red); }
.badge-unknown { background: var(--bg-hover); color: var(--text-muted); }

/* ---- Status Icon ---- */
.status-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; font-size: 16px; flex-shrink: 0; }
.status-icon.healthy { background: var(--green-bg); color: var(--green); }
.status-icon.warning { background: var(--yellow-bg); color: var(--yellow); }
.status-icon.critical { background: var(--red-bg); color: var(--red); }
.status-icon.unknown { background: var(--bg-hover); color: var(--text-muted); }

/* ========================================
   Site Cards Grid (Dashboard)
   ======================================== */
.site-cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.site-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.site-card:hover { box-shadow: var(--shadow-md); }

.site-card--healthy { border-left: 4px solid var(--green); }
.site-card--warning { border-left: 4px solid var(--yellow); }
.site-card--critical { border-left: 4px solid var(--red); }
.site-card--unknown { border-left: 4px solid var(--text-muted); }

.site-card__header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 12px; }
.site-card__status { display: flex; align-items: center; gap: 12px; }
.site-card__name { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.site-card__url { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.site-card__actions { flex-shrink: 0; }

.site-card__summary {
    padding: 0 24px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.site-card__summary-text { font-size: 13.5px; color: var(--text-secondary); }
.site-card__time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

.site-card__metrics {
    display: flex;
    gap: 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--bg-input);
}
.metric {
    flex: 1;
    padding: 12px 20px;
    text-align: center;
    border-right: 1px solid var(--border);
}
.metric:last-child { border-right: none; }
.metric__label { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-muted); margin-bottom: 4px; }
.metric__value { font-size: 14px; font-weight: 700; }
.metric--good { color: var(--green); }
.metric--bad { color: var(--red); }
.metric--green { color: var(--green); }
.metric--yellow { color: var(--yellow); }
.metric--orange { color: var(--orange); }
.metric--red { color: var(--red); }

/* ---- Issue Rows in Site Card ---- */
.site-card__issues { padding: 16px 24px; border-bottom: 1px solid var(--border); }

.issue-row {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}
.issue-row:last-child { margin-bottom: 0; }
.issue-row--warning { background: var(--yellow-soft); }
.issue-row--critical { background: var(--red-soft); }
.issue-row__icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.issue-row__content { flex: 1; }
.issue-row__content strong { font-size: 13.5px; display: block; margin-bottom: 2px; }
.issue-row__content p { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
.issue-row__details { margin-top: 6px; }
.issue-row__details summary { font-size: 12px; color: var(--accent); cursor: pointer; font-weight: 600; }
.issue-row__details ul { margin: 6px 0 0 16px; font-size: 12px; font-family: var(--font-mono); color: var(--text-secondary); }
.issue-row__details li { margin-bottom: 2px; }

/* ---- Site Card Footer ---- */
.site-card__footer {
    display: flex;
    gap: 4px;
    padding: 12px 24px;
    background: var(--bg-input);
}
.site-card__footer a {
    padding: 5px 12px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.site-card__footer a:hover { background: var(--accent-soft); }

/* ========================================
   Site Detail Page
   ======================================== */
.status-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}
.status-banner--healthy { background: var(--green-soft); border: 1px solid #bbf7d0; }
.status-banner--warning { background: var(--yellow-soft); border: 1px solid #fde68a; }
.status-banner--critical { background: var(--red-soft); border: 1px solid #fecaca; }
.status-banner--unknown { background: var(--bg-hover); border: 1px solid var(--border); }
.status-banner__icon { font-size: 24px; }
.status-banner__icon .status-icon { width: 44px; height: 44px; font-size: 22px; }
.status-banner__text { flex: 1; }
.status-banner__text strong { font-size: 16px; display: block; margin-bottom: 2px; }
.status-banner__text span { font-size: 13px; color: var(--text-secondary); }

.detail-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-bottom: 4px;
}
.detail-metric {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    box-shadow: var(--shadow-sm);
}
.detail-metric__icon {
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.dm--good { background: var(--green-bg); color: var(--green); }
.dm--bad { background: var(--red-bg); color: var(--red); }
.dm--yellow { background: var(--yellow-bg); color: var(--yellow); }
.dm--orange { background: #ffedd5; color: var(--orange); }
.dm--neutral { background: var(--bg-hover); color: var(--text-muted); }
.dm--green { background: var(--green-bg); color: var(--green); }
.dm--red { background: var(--red-bg); color: var(--red); }

.detail-metric__label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 4px; }
.detail-metric__value { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; }
.detail-metric__desc { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }

/* ---- Issues Detail ---- */
.issues-list { display: grid; gap: 12px; }
.issue-detail {
    border-radius: var(--radius-sm);
    padding: 18px 20px;
}
.issue-detail--warning { background: var(--yellow-soft); border: 1px solid #fde68a; }
.issue-detail--critical { background: var(--red-soft); border: 1px solid #fecaca; }
.issue-detail__header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.issue-detail__icon { font-size: 24px; }
.issue-detail__header strong { font-size: 15px; }
.issue-detail__header .badge { margin-left: 8px; }
.issue-detail__explanation { font-size: 14px; line-height: 1.6; color: var(--text-secondary); margin-bottom: 8px; }

.issue-detail__files { margin-top: 10px; }
.issue-detail__files summary { font-size: 13px; font-weight: 600; color: var(--accent); cursor: pointer; margin-bottom: 8px; }
.issue-file-list { display: grid; gap: 4px; }
.issue-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.6);
    border-radius: 4px;
    font-size: 12.5px;
}
.issue-file code { font-family: var(--font-mono); font-weight: 600; font-size: 12px; }
.issue-file__path { color: var(--text-muted); font-family: var(--font-mono); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- History Rows ---- */
.history-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.history-row:last-child { border-bottom: none; }
.history-row__status { flex-shrink: 0; }
.history-row__info { flex: 1; min-width: 0; }
.history-row__info strong { font-size: 13.5px; display: block; margin-bottom: 2px; }
.history-row__time { font-size: 12px; color: var(--text-muted); }
.history-row__metrics { display: flex; gap: 6px; flex-shrink: 0; }
.history-pill {
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--bg-hover);
    color: var(--text-secondary);
}
.history-pill--bad { background: var(--red-soft); color: var(--red); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead { border-bottom: 2px solid var(--border); }
th { text-align: left; padding: 10px 14px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-muted); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: var(--bg-hover); }
.td-url { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-secondary); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-actions { white-space: nowrap; }
.td-actions a { display: inline-flex; padding: 4px 10px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 500; text-decoration: none; color: var(--accent); transition: all 0.15s; }
.td-actions a:hover { background: var(--accent-soft); }
.td-actions a.danger { color: var(--red); }
.td-actions a.danger:hover { background: var(--red-soft); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; border-radius: var(--radius-sm);
    font-family: var(--font-body); font-size: 13.5px; font-weight: 600;
    border: none; cursor: pointer; text-decoration: none;
    transition: all 0.15s ease; line-height: 1.4;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-hover); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border-strong); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.form-group .form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
input[type="text"], input[type="email"], input[type="password"],
input[type="url"], input[type="number"], select, textarea {
    width: 100%; padding: 9px 14px;
    font-family: var(--font-body); font-size: 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-input); color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: auto; }

.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.checkbox-row label { margin: 0; font-weight: 500; cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---- Login ---- */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px 36px; box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px; letter-spacing: -0.5px; }
.login-card .subtitle { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 28px; color: var(--text-primary); font-weight: 700; font-size: 18px; }
.login-toggle { text-align: center; margin-top: 20px; font-size: 13.5px; color: var(--text-secondary); }
.login-toggle a { color: var(--accent); text-decoration: none; font-weight: 600; }
.login-toggle a:hover { text-decoration: underline; }
.login-error { background: var(--red-soft); color: var(--red); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; border: 1px solid #fecaca; }

/* ---- Notifications ---- */
.notif-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex-shrink: 0; }
.notif-content { flex: 1; }
.notif-content strong { font-size: 13.5px; }
.notif-content p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.notif-time { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }

/* ---- Empty State ---- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state svg { margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 13.5px; margin-bottom: 16px; }

/* ---- Log Bars (legacy logs page) ---- */
.log-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 6px; }
.log-bar.healthy { background: var(--green-soft); }
.log-bar.warning { background: var(--yellow-soft); }
.log-bar.critical { background: var(--red-soft); }
.log-bar .log-time { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); min-width: 140px; }
.log-bar .log-status { font-weight: 600; min-width: 80px; }
.log-bar .log-detail { color: var(--text-secondary); flex: 1; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .nav-container { gap: 12px; }
    .nav-links a { padding: 6px 8px; font-size: 12.5px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .site-card__metrics { flex-wrap: wrap; }
    .metric { min-width: 50%; }
    .detail-metrics { grid-template-columns: 1fr; }
    .status-banner { flex-wrap: wrap; }
    .history-row { flex-wrap: wrap; }
    .history-row__metrics { width: 100%; margin-top: 4px; }
}
