/* © 2026 KIETTISAK CO.,LTD. — All rights reserved. (developed under contract) */
/* MA-NCW — ธีมพอร์ตจาก NCW-CMMS (Blazor MainLayout/NavMenu/app.css) ให้หน้าตาเหมือนเดิม */

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, 'Leelawadee UI', 'Segoe UI', sans-serif;
    margin: 0;
}

a, .btn-link { color: #006bb7; }

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content { padding-top: 1.1rem; }

h1:focus { outline: none; }
.validation-message { color: #e50000; }

/* ===== โครงหน้า (MainLayout) ===== */
.page {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main { flex: 1; display: flex; flex-direction: column; }
main article { flex: 1; }

.sidebar {
    background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
}

.top-row {
    background-color: #f7f7f7;
    border-bottom: 1px solid #d6d5d5;
    justify-content: flex-end;
    height: 3.5rem;
    display: flex;
    align-items: center;
}

.top-row a, .top-row .btn-link {
    white-space: nowrap;
    margin-left: 1.5rem;
    text-decoration: none;
}

.app-footer { border-top: 1px solid #e5e5e5; background: #fafafa; }

@media (max-width: 640.98px) {
    .top-row { justify-content: space-between; }
    .top-row a, .top-row .btn-link { margin-left: 0; }
}

@media (min-width: 641px) {
    .page { flex-direction: row; }

    .sidebar {
        width: 250px;
        height: 100vh;
        position: sticky;
        top: 0;
    }

    .top-row {
        position: sticky;
        top: 0;
        z-index: 1;
    }

    .top-row, article {
        padding-left: 2rem !important;
        padding-right: 1.5rem !important;
    }
}

/* ===== เมนูข้าง (NavMenu) ===== */
.navbar-toggler {
    appearance: none;
    cursor: pointer;
    width: 3.5rem;
    height: 2.5rem;
    color: white;
    position: absolute;
    top: 0.5rem;
    right: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1);
}

.navbar-toggler:checked { background-color: rgba(255, 255, 255, 0.5); }

.sidebar .top-row {
    height: 3.5rem;
    background-color: rgba(0,0,0,0.4);
    border-bottom: none;
    justify-content: flex-start;
}

.navbar-brand { font-size: 1.1rem; color: #fff; }
.brand-logo {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.5);
}

.nav-ico {
    display: inline-block;
    width: 1.4rem;
    margin-right: 0.6rem;
    text-align: center;
}

.nav-item { font-size: 0.9rem; padding-bottom: 0.5rem; }
.nav-item:first-of-type { padding-top: 1rem; }
.nav-item:last-of-type { padding-bottom: 1rem; }

.nav-item .nav-link {
    color: #d7d7d7;
    background: none;
    border: none;
    border-radius: 4px;
    height: 3rem;
    display: flex;
    align-items: center;
    line-height: 3rem;
    width: 100%;
    padding: 0 0.75rem;
    text-decoration: none;
}

.nav-item a.active {
    background-color: rgba(255,255,255,0.37);
    color: white;
}

.nav-item .nav-link:hover {
    background-color: rgba(255,255,255,0.1);
    color: white;
}

.nav-user { cursor: default; }

.nav-scrollable { display: none; }
.navbar-toggler:checked ~ .nav-scrollable { display: block; }

@media (min-width: 641px) {
    .navbar-toggler { display: none; }
    .nav-scrollable {
        display: block;
        height: calc(100vh - 3.5rem);
        overflow-y: auto;
    }
}

/* ===== หน้า login ===== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.login-logo {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 0 auto 1rem;
    border: 3px solid rgb(5, 39, 103);
}

/* การ์ดลิงก์หน้าหลัก */
a.card { transition: transform .1s ease-in-out, box-shadow .1s; }
a.card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,0.12); }

/* ตาราง */
.table > :not(caption) > * > * { vertical-align: middle; }
.low-stock { background: #fff0f0 !important; }

/* ===== รายงาน/KPI ===== */
.card.kpi { text-align: center; }
.kpi-num { font-size: 2.2rem; font-weight: 700; color: rgb(5, 39, 103); }

/* ===== Executive Dashboard ===== */
.exec-hero {
    background-image: linear-gradient(120deg, rgb(5, 39, 103) 0%, #3a0647 100%);
    color: #fff;
    border-radius: 14px;
    padding: 1.1rem 1.5rem;
    margin-top: .5rem;
    box-shadow: 0 6px 24px rgba(5, 39, 103, .35);
}
.exec-logo { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.6); }
.exec-title { font-size: 1.45rem; font-weight: 700; letter-spacing: .02em; }
.exec-sub { opacity: .8; font-size: .85rem; }
.exec-clock { font-size: 1.2rem; font-variant-numeric: tabular-nums; font-weight: 600; }

.exec-kpi { border: none; box-shadow: 0 2px 10px rgba(0,0,0,.07); border-top: 4px solid #cfd8e6; }
.exec-kpi.edge-good { border-top-color: #059669; }
.exec-kpi.edge-warn { border-top-color: #ffc107; }
.exec-kpi.edge-bad  { border-top-color: #dc3545; }
.exec-kpi .card-body { padding: .8rem .5rem; }
.exec-kpi .kpi-num { font-size: 2rem; line-height: 1.1; }
.kpi-cap { color: #6b7683; font-size: .8rem; margin-top: .15rem; }

.exec-stations { display: flex; flex-wrap: wrap; gap: .5rem; }
.exec-station {
    display: flex; align-items: center; gap: .45rem;
    padding: .4rem .7rem;
    border-radius: 999px;
    border: 1px solid #e3e8ee;
    background: #f8fafc;
    text-decoration: none;
    color: #243447;
    font-size: .85rem;
    transition: transform .08s, box-shadow .08s;
}
.exec-station:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,0,0,.12); color: #243447; }
.st-dot { width: .85rem; height: .85rem; border-radius: 50%; flex: none; }
.st-good .st-dot { background: #059669; box-shadow: 0 0 6px rgba(5,150,105,.55); }
.st-warn .st-dot { background: #ffc107; box-shadow: 0 0 6px rgba(255,193,7,.6); }
.st-bad  .st-dot { background: #dc3545; box-shadow: 0 0 6px rgba(220,53,69,.6); animation: pulse-bad 1.2s infinite; }
@keyframes pulse-bad { 50% { box-shadow: 0 0 12px rgba(220,53,69,.95); } }
.st-pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.st-good .st-pct { color: #059669; }
.st-warn .st-pct { color: #b38f00; }
.st-bad  .st-pct { color: #dc3545; }

/* ===== permissions matrix ===== */
.perm-matrix td, .perm-matrix th { font-size: 0.85rem; }
.perm-matrix input[type=checkbox] { transform: scale(1.15); }

/* ===== สถานะความพร้อม (readiness) ===== */
.rdot { font-size: 1.25rem; line-height: 1; cursor: default; }
.dot-green  { color: #198754; }
.dot-yellow { color: #ffc107; text-shadow: 0 0 1px #b38f00; }
.dot-red    { color: #dc3545; }
.dot-none   { color: #cfd4da; }
.readiness-tbl th.rot-head { max-width: 5.5rem; font-weight: 600; }
.readiness-tbl td, .readiness-tbl th { padding: .35rem .4rem; }

/* ===== คู่มือ (help) ===== */
details.help {
    background: #fff;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    padding: 0;
}
details.help summary {
    cursor: pointer;
    font-weight: 600;
    padding: 0.8rem 1rem;
}
details.help[open] summary { border-bottom: 1px solid #eee; }
details.help > div { padding: 0.9rem 1.25rem; }
