/* DocPort — MSH Design System (Thymeleaf) */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&family=Roboto+Slab:wght@400;700&display=swap');

:root {
    --msh-primary: #0076A7;
    --msh-secondary: #D26DA1;
    --msh-text: #454A4E;
    --msh-success: #18BC9C;
    --msh-info: #29BDEF;
    --msh-warning: #F39C12;
    --msh-error: #E74C3C;
    --msh-cancel: #86898C;
    --msh-bg: #FFFFFF;
    --msh-bg-alt: #F0F0F0;
    --msh-border: rgba(69, 74, 78, 0.2);
    --msh-shadow: 0px 3px 6px #CCC;
    --msh-radius: 3px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Roboto', sans-serif;
    background: var(--msh-bg);
    color: var(--msh-text);
    margin: 0;
    font-size: 16px;
    line-height: 1.5;
}

h1, h2, h3 {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    padding-bottom: 0;
    margin-bottom: 10px;
    position: relative;
}
h1::after, h2::after {
    content: '';
    display: block;
    width: 100%;
    padding-top: 15px;
    border-bottom: 1px solid var(--msh-border);
}
h1 { font-size: 1.5625rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.125rem; }
h1 small { font-family: 'Roboto', sans-serif; font-weight: 400; font-size: 0.85rem; }

a { color: var(--msh-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation (80px App Bar) ── */
nav.topbar {
    background: var(--msh-primary);
    color: #fff;
    display: flex;
    align-items: center;
    height: 80px;
    padding: 0;
    gap: 0;
}
nav.topbar .brand {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 80px;
    padding: 0 24px;
    border-right: 1px solid rgba(255,255,255,0.2);
}
nav.topbar .nav-links {
    display: flex;
    align-items: center;
    gap: 0;
    height: 80px;
}
nav.topbar .nav-links a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 0 20px;
    height: 80px;
    display: flex;
    align-items: center;
    transition: background 0.15s, color 0.15s;
}
nav.topbar .nav-links a:hover,
nav.topbar .nav-links a.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
}
nav.topbar .spacer { flex: 1; }
nav.topbar .user-info {
    font-size: 0.85rem;
    opacity: 0.85;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}
nav.topbar .user-info .mdi { font-size: 1.2rem; }
nav.topbar .nav-actions {
    display: flex;
    align-items: center;
    height: 80px;
    border-left: 1px solid rgba(255,255,255,0.2);
    padding: 0 16px;
}

/* ── Main content ── */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px;
}
@media (min-width: 820px)  { main { padding: 24px 110px; max-width: unset; } }
@media (min-width: 1600px) { main { padding: 24px 300px; } }

/* ── Cards ── */
.card {
    background: var(--msh-bg);
    box-shadow: var(--msh-shadow);
    border-radius: var(--msh-radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.card h2 {
    margin-top: 0;
    font-size: 1.2rem;
}
.card h2::after { display: none; }

/* ── Status Grid (Dashboard) ── */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 1.25rem;
}
.status-tile {
    background: var(--msh-bg);
    box-shadow: var(--msh-shadow);
    border-radius: var(--msh-radius);
    padding: 12px 16px;
    text-align: center;
    border-left: 4px solid transparent;
}
.status-tile .count { font-size: 1.8rem; font-weight: 700; color: var(--msh-text); }
.status-tile .label { font-size: 0.8rem; color: var(--msh-cancel); margin-top: 2px; }
.status-tile.error  { border-left-color: var(--msh-error); }
.status-tile.error .count { color: var(--msh-error); }
.status-tile.success { border-left-color: var(--msh-success); }
.status-tile.success .count { color: var(--msh-success); }
.status-tile.warn   { border-left-color: var(--msh-warning); }
.status-tile.warn .count { color: var(--msh-warning); }
.status-tile.info   { border-left-color: var(--msh-info); }
.status-tile.info .count { color: var(--msh-info); }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th {
    padding: 0 10px 12px;
    text-align: left;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--msh-text);
    border-bottom: 1px solid #515151;
}
td {
    padding: 0 10px;
    height: 52px;
    vertical-align: middle;
    border-bottom: 1px solid var(--msh-border);
}
tbody tr:nth-child(even) td { background: #F9F9F9; }
tbody tr:nth-child(odd) td  { background: #FFFFFF; }

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--msh-radius);
    font-size: 0.85rem;
    font-weight: 400;
    color: #fff;
}
.badge-error   { background: var(--msh-error); }
.badge-success { background: var(--msh-success); }
.badge-warn    { background: var(--msh-warning); }
.badge-info    { background: var(--msh-info); }
.badge-muted   { background: var(--msh-cancel); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--msh-radius);
    font-size: 0.9rem;
    font-weight: 400;
    cursor: pointer;
    text-decoration: none;
    text-transform: none;
    box-shadow: none;
    height: 38px;
    transition: filter 0.15s;
    font-family: 'Roboto', sans-serif;
}
.btn:hover { filter: brightness(0.9); text-decoration: none; }
.btn-primary   { background: var(--msh-secondary); color: #fff; }
.btn-secondary { background: var(--msh-primary); color: #fff; }
.btn-danger    { background: var(--msh-error); color: #fff; }
.btn-cancel    { background: var(--msh-cancel); color: #fff; }
.btn-test {
    background: transparent;
    border: 1px solid var(--msh-primary);
    color: var(--msh-primary);
    padding: 2px 12px;
    font-size: 0.8rem;
    height: auto;
    margin-left: 12px;
    vertical-align: middle;
}
.btn-test:hover { background: var(--msh-primary); color: #fff; }
.btn-test:disabled { opacity: 0.6; cursor: wait; }
.btn-sm { padding: 4px 10px; font-size: 0.85rem; height: 30px; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--msh-border);
    color: var(--msh-text);
}
.btn-outline:hover { background: var(--msh-bg-alt); }
.btn .mdi { font-size: 1.1rem; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-weight: 400;
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: var(--msh-text);
}
.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 16px;
    border: 1px solid rgba(69, 74, 78, 0.5);
    border-radius: var(--msh-radius);
    font-size: 0.9rem;
    font-family: 'Roboto', sans-serif;
    color: var(--msh-text);
    background: var(--msh-bg);
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--msh-primary);
}
.form-group input:disabled {
    background: var(--msh-bg-alt);
    border: none;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-hint { font-size: 0.8rem; color: var(--msh-cancel); margin-top: 4px; }

fieldset {
    border: 1px solid var(--msh-border);
    border-radius: var(--msh-radius);
    padding: 1rem;
    margin-bottom: 1rem;
}
legend {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0 8px;
    color: var(--msh-text);
}

/* ── Flash messages ── */
.flash {
    padding: 10px 16px;
    border-radius: var(--msh-radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.flash-success {
    background: rgba(24, 188, 156, 0.1);
    color: #0e7a60;
    border: 1px solid rgba(24, 188, 156, 0.3);
}
.flash-error {
    background: rgba(231, 76, 60, 0.1);
    color: #c0392b;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

/* ── Connection test results ── */
.test-result {
    padding: 10px 16px;
    border-radius: var(--msh-radius);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.test-ok {
    background: rgba(24, 188, 156, 0.1);
    color: #0e7a60;
    border: 1px solid rgba(24, 188, 156, 0.3);
}
.test-fail {
    background: rgba(231, 76, 60, 0.1);
    color: #c0392b;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

/* ── Job detail ── */
.detail-grid {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 6px 16px;
    align-items: baseline;
}
.detail-label {
    font-size: 0.85rem;
    color: var(--msh-cancel);
    font-weight: 400;
}
.detail-value {
    font-size: 0.9rem;
}
.ocr-block, .json-block, .error-block {
    background: var(--msh-bg-alt);
    border: 1px solid var(--msh-border);
    border-radius: var(--msh-radius);
    padding: 16px;
    font-size: 0.8rem;
    line-height: 1.6;
    max-height: 400px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Roboto Mono', 'Consolas', monospace;
}
.error-block {
    background: rgba(231, 76, 60, 0.05);
    border-color: rgba(231, 76, 60, 0.2);
    color: #c0392b;
}
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: rgba(0, 118, 167, 0.05); }
.job-link {
    color: var(--msh-primary);
    text-decoration: none;
    font-weight: 700;
}
.job-link:hover { text-decoration: underline; }

/* ── Login page ── */
.login-page {
    background: var(--msh-bg-alt);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--msh-bg);
    box-shadow: var(--msh-shadow);
    border-radius: var(--msh-radius);
    padding: 2rem;
}
.login-box .login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}
.login-box .login-header h1 {
    font-family: 'Roboto Slab', serif;
    font-size: 1.5rem;
    color: var(--msh-primary);
    margin: 0;
}
.login-box .login-header h1::after { display: none; }
.login-box .login-header p {
    font-size: 0.85rem;
    color: var(--msh-cancel);
    margin: 4px 0 0;
}
.login-box .btn { width: 100%; justify-content: center; margin-top: 8px; }

/* ── Utility ── */
.text-muted { color: var(--msh-cancel); }
.text-right { text-align: right; }
.mt-1 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
    .status-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    nav.topbar .nav-links a { padding: 0 12px; font-size: 0.85rem; }
}
