/* DeCrawler – Custom Styles (PicoCSS v2 Override)
   UI Review: Sophie (UI-Design) + Finn (Frontend), mainagentur */

/* ============================================================
   FOUNDATION: Typography, Numbers, Layout
   ============================================================ */

/* Tabular numbers everywhere — digits get equal width */
body {
    font-variant-numeric: tabular-nums;
}

/* Monospace for all numbers in tables and cards */
.num, td.num, th.num,
article h3,
.stat-value {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    letter-spacing: -0.01em;
}

/* Navigation */
nav .contrast {
    font-weight: bold;
    text-decoration: underline;
}
nav ul {
    justify-content: center;
    gap: 1rem;
}

footer {
    margin-top: 2rem;
    padding: 1rem 0;
    text-align: center;
    color: var(--muted-color);
}

/* ============================================================
   STATS CARDS (Dashboard Kacheln)
   ============================================================ */

/* Card grid: max 4 per row on desktop, wrapping evenly */
#stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

#stats-cards article {
    margin-bottom: 0;
    padding: 1rem 1.2rem;
    text-align: center;
}

#stats-cards article h3 {
    font-size: 1.6rem;
    margin-bottom: 0.1rem;
    line-height: 1.2;
    white-space: nowrap;
}

#stats-cards article p {
    margin: 0;
    font-size: 0.78rem;
    color: var(--muted-color);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ============================================================
   TABLES: Alignment, Sizing, Readability
   ============================================================ */

table {
    font-size: 0.88rem;
    width: 100%;
}

table th,
table td {
    padding: 0.35rem 0.6rem;
    vertical-align: middle;
}

/* Right-align numeric columns */
table td.num,
table th.num,
td:has(> span[style*="color"]),  /* PageSpeed scores etc */
table td:nth-child(n+3) {
    text-align: center;
}

/* First column (domain names) gets space */
table td:first-child {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Compact header */
table thead th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted-color);
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid var(--muted-border-color);
}

/* Subtle row hover */
table tbody tr:hover {
    background: rgba(0,0,0,0.02);
}

/* Compact rows */
table tbody td {
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

/* Domain list table: fixed layout for consistent columns */
#domain-results table {
    table-layout: fixed;
}
#domain-results table th:nth-child(1) { width: 28%; }  /* Domain */
#domain-results table th:nth-child(2) { width: 10%; }  /* CMS */
#domain-results table th:nth-child(3) { width: 7%; }   /* Conf */
#domain-results table th:nth-child(4) { width: 7%; }   /* CLAUDE */
#domain-results table th:nth-child(5) { width: 7%; }   /* Status */
#domain-results table th:nth-child(6) { width: 5%; }   /* PS */
#domain-results table th:nth-child(7) { width: 5%; }   /* IMP */
#domain-results table th:nth-child(8) { width: 5%; }   /* Redir */
#domain-results table th:nth-child(9) { width: 26%; }  /* Datum */

/* ============================================================
   STATUS BADGES & INDICATORS
   ============================================================ */

ins {
    text-decoration: none;
    background-color: #d4edda;
    color: #155724;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 500;
}

del {
    text-decoration: none;
    background-color: #f8d7da;
    color: #721c24;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 500;
}

mark {
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 500;
}

/* PageSpeed score pill */
.ps-score {
    display: inline-block;
    min-width: 2rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}
.ps-good  { background: #d4edda; color: #155724; }
.ps-ok    { background: #fff3cd; color: #856404; }
.ps-bad   { background: #f8d7da; color: #721c24; }

/* ============================================================
   GRID & CARDS
   ============================================================ */

.grid > article {
    margin-bottom: 0;
}

/* Domain detail cards: equal height in grid */
.grid {
    align-items: start;
}

/* ============================================================
   SYSTEM-LIVE TILES (Stats Page)
   ============================================================ */

progress.bar-warn::-webkit-progress-value { background-color: #f39c12; }
progress.bar-warn::-moz-progress-bar { background-color: #f39c12; }
progress.bar-danger::-webkit-progress-value { background-color: #e74c3c; }
progress.bar-danger::-moz-progress-bar { background-color: #e74c3c; }

#system-live progress {
    margin-bottom: 0;
    height: 1.2rem;
}

.sys-tile {
    padding-bottom: 0.5rem;
}

.sys-tile header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tile-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    white-space: nowrap;
}
.badge-ok    { background: #d4edda; color: #155724; }
.badge-warn  { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }

.progress-label {
    display: block;
    margin-top: -0.3rem;
    margin-bottom: 0.5rem;
    color: var(--muted-color);
    font-size: 0.78rem;
}

/* Breakdown tables (RAM, CPU, Throughput) */
.breakdown-table {
    width: 100%;
    font-size: 0.82rem;
    margin-top: 0.3rem;
}

.breakdown-table td {
    padding: 0.2rem 0.4rem;
    border: none;
}

.breakdown-table .num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.breakdown-table .pid {
    text-align: right;
    opacity: 0.35;
    font-size: 0.72rem;
    white-space: nowrap;
}

.breakdown-footer td {
    border-top: 2px solid var(--muted-border-color);
    padding-top: 0.4rem;
    font-weight: 600;
}

.breakdown-sep td {
    padding-top: 0.6rem;
}

.section-label {
    opacity: 0.5;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Color dots for breakdown */
.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.3rem;
    vertical-align: middle;
}
.dot-crawler    { background-color: #e74c3c; }
.dot-web        { background-color: #3498db; }
.dot-enrichment { background-color: #1abc9c; }
.dot-cache      { background-color: #95a5a6; }
.dot-other      { background-color: #bdc3c7; }
.dot-ok         { background-color: #2ecc71; }
.dot-warn       { background-color: #f39c12; }
.dot-danger     { background-color: #e74c3c; }

.inline-progress {
    width: 80px;
    height: 0.8rem;
    display: inline-block;
    vertical-align: middle;
    margin-bottom: 0;
    margin-right: 0.3rem;
}

.text-danger { color: #e74c3c; }
.text-warn   { color: #f39c12; }
.text-ok     { color: #2ecc71; }

/* ============================================================
   DOMAIN DETAIL PAGE
   ============================================================ */

/* Enrichment section heading */
#domain-results + h3,
h3:has(+ .grid article header) {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

/* Detail tables: key-value layout */
.grid article table td:first-child {
    white-space: nowrap;
    color: var(--muted-color);
    font-size: 0.82rem;
    width: 35%;
}

/* Redirect warning box */
article[style*="border-left: 3px solid"] {
    padding: 0.8rem 1.2rem;
    margin-top: 0.5rem;
}

/* ============================================================
   FILTER FORM (Domain List)
   ============================================================ */

.filter-form select,
.filter-form input[type=search] {
    margin-bottom: 0;
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
}

.filter-row {
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Loading state */
#domain-results {
    position: relative;
    min-height: 200px;
    transition: opacity 0.15s;
}
#domain-results.loading {
    opacity: 0.3;
    pointer-events: none;
}
#load-spinner {
    display: none;
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
}
#load-spinner.show { display: block; }
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #ddd;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-count {
    transition: opacity 0.15s;
}
.result-count.dim { opacity: 0.3; }

/* ============================================================
   PAGINATION
   ============================================================ */

nav ul {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

nav ul li {
    font-size: 0.85rem;
    white-space: nowrap;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    #stats-cards {
        grid-template-columns: repeat(3, 1fr);
    }

    #stats-cards article h3 {
        font-size: 1.2rem;
    }

    #domain-results table {
        table-layout: auto;
    }

    /* Hide less important columns on mobile */
    #domain-results table th:nth-child(3),
    #domain-results table td:nth-child(3),
    #domain-results table th:nth-child(8),
    #domain-results table td:nth-child(8),
    #domain-results table th:nth-child(9),
    #domain-results table td:nth-child(9) {
        display: none;
    }

    .filter-form .grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    #stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    #stats-cards article h3 {
        font-size: 1rem;
    }

    #domain-results table th:nth-child(4),
    #domain-results table td:nth-child(4),
    #domain-results table th:nth-child(6),
    #domain-results table td:nth-child(6),
    #domain-results table th:nth-child(7),
    #domain-results table td:nth-child(7) {
        display: none;
    }

    .filter-form .grid {
        grid-template-columns: 1fr;
    }
}
