/* ===== Lee Work — design system (mobile-first) ===== */

:root {
    --w-bg: #f2f4f3;
    --w-surface: #ffffff;
    --w-border: #e2e6e4;
    --w-border-strong: #cfd6d2;
    --w-text: #171c1a;
    --w-muted: #687470;
    --w-primary: #0f6b4f;
    --w-primary-dark: #0a4f3a;
    --w-primary-soft: #e6f4ee;
    --w-primary-soft-border: #b6dfca;
    --w-primary-gradient: linear-gradient(135deg, #12805e 0%, #0a4f3a 100%);
    --w-danger: #d92d20;
    --w-danger-soft: #fef3f2;
    --w-danger-border: #fecdca;
    --w-radius-lg: 16px;
    --w-radius: 12px;
    --w-radius-sm: 10px;
    --w-shadow: 0 1px 2px rgba(15, 23, 20, .04), 0 6px 18px rgba(15, 23, 20, .06);
    --w-shadow-up: 0 -4px 18px rgba(15, 23, 20, .08);
    --w-safe-b: env(safe-area-inset-bottom, 0px);
}

html, body { -webkit-text-size-adjust: 100%; }
* { -webkit-tap-highlight-color: transparent; }

body {
    background: var(--w-bg);
    color: var(--w-text);
    font-family: "Noto Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--w-primary); }
a:hover { color: var(--w-primary-dark); }
button:focus, .btn:focus, a:focus { outline: none; box-shadow: none; }

/* ================= navbar (collapse on mobile) ================= */
.app-navbar {
    background: var(--w-surface);
    border-bottom: 1px solid var(--w-border);
    padding: 0;
}
.app-navbar-inner {
    width: 100%; max-width: 640px; margin: 0 auto;
    padding: 0 12px 0 16px;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
}
.app-navbar .navbar-brand { padding: 0; margin: 0; }
.brand {
    display: flex; align-items: center; gap: 9px; height: 58px;
    color: var(--w-text); font-weight: 700; font-size: 16px; text-decoration: none;
}
.brand:hover { text-decoration: none; color: var(--w-text); }
.brand-mark {
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--w-primary-gradient); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 17px;
    box-shadow: 0 2px 6px rgba(15, 107, 79, .35);
}
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--w-muted); line-height: 1.1; }

.app-navbar .navbar-toggler {
    width: 44px; height: 44px; padding: 0; border: 1px solid var(--w-border);
    border-radius: var(--w-radius-sm); color: var(--w-text); font-size: 24px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center; background: var(--w-surface);
}
.app-navbar .navbar-toggler:active { background: var(--w-bg); }
.app-navbar .navbar-toggler .icon-close { display: none; font-size: 18px; }
.app-navbar .navbar-toggler[aria-expanded="true"] .icon-open { display: none; }
.app-navbar .navbar-toggler[aria-expanded="true"] .icon-close { display: inline; }

.app-navbar .nav-link {
    display: flex; align-items: center; gap: 12px;
    color: var(--w-text); font-size: 15px; font-weight: 500;
}
.app-navbar .nav-link i:first-child { font-size: 19px; color: var(--w-muted); }
.app-navbar .nav-link.active { color: var(--w-primary-dark); }
.app-navbar .nav-link.active i:first-child { color: var(--w-primary); }
.app-navbar .nav-chev { margin-left: auto; font-size: 13px; color: var(--w-border-strong); }

.user-avatar {
    width: 36px; height: 36px; border-radius: 50%; flex: none;
    background: var(--w-primary-soft); color: var(--w-primary-dark);
    border: 1px solid var(--w-primary-soft-border);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
}

/* -- mobile (collapsed panel) -- */
@media (max-width: 767.98px) {
    .app-navbar .navbar-collapse {
        width: 100%; flex-basis: 100%;
        border-top: 1px solid var(--w-border);
        margin: 0 -12px 0 -16px; padding: 8px 12px 14px 12px; width: calc(100% + 28px);
        background: var(--w-surface);
    }
    .app-navbar .nav-item + .nav-item { margin-top: 4px; }
    .app-navbar .nav-link {
        min-height: 50px; padding: 8px 12px !important;
        border-radius: var(--w-radius-sm);
    }
    .app-navbar .nav-link:active { background: var(--w-bg); }
    .app-navbar .nav-link.active { background: var(--w-primary-soft); }
    .nav-mobile-user {
        margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--w-border);
    }
    .nav-mobile-user-row { display: flex; align-items: center; gap: 12px; padding: 6px 12px 10px; }
    .nav-mobile-user-row small { display: block; font-size: 11.5px; color: var(--w-muted); line-height: 1.2; }
    .nav-mobile-user-row b { font-size: 15px; font-weight: 600; }
    .nav-logout {
        display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 8px 12px;
        border-radius: var(--w-radius-sm); color: var(--w-danger); font-size: 15px; font-weight: 500;
        text-decoration: none;
    }
    .nav-logout i { font-size: 19px; }
    .nav-logout:active, .nav-logout:hover { background: var(--w-danger-soft); color: var(--w-danger); text-decoration: none; }
}

/* -- desktop (inline) -- */
@media (min-width: 768px) {
    .app-navbar .navbar-toggler { display: none; }
    .app-navbar .navbar-nav { align-items: center; gap: 4px; }
    .app-navbar .nav-link { height: 40px; padding: 0 14px !important; border-radius: var(--w-radius-sm); gap: 8px; }
    .app-navbar .nav-link i:first-child { font-size: 17px; }
    .app-navbar .nav-link:hover { background: var(--w-bg); }
    .app-navbar .nav-link.active { background: var(--w-primary-soft); }
    .app-navbar .nav-chev { display: none; }
    .user-menu { margin-left: 8px; }
    .user-menu .user-toggle { padding: 0 8px 0 4px !important; gap: 8px; }
    .user-menu .user-toggle::after { color: var(--w-muted); }
    .user-menu .dropdown-menu {
        border: 1px solid var(--w-border); border-radius: var(--w-radius);
        box-shadow: var(--w-shadow); padding: 6px; min-width: 180px; margin-top: 8px;
    }
    .user-menu .dropdown-item {
        border-radius: 8px; padding: 9px 10px; font-size: 14px;
        display: flex; align-items: center; gap: 9px;
    }
    .user-menu .dropdown-item.text-danger:hover { background: var(--w-danger-soft); }
}

/* ================= layout ================= */
.wrap {
    max-width: 640px; margin: 0 auto;
    padding: 18px 16px calc(120px + var(--w-safe-b));
}
.page-head { margin-bottom: 16px; }
.page-head h1 { font-size: 21px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-head p { margin: 2px 0 0; font-size: 13px; color: var(--w-muted); }
.page-title { font-size: 19px; font-weight: 700; margin: 0 0 16px; }

/* ================= section cards ================= */
.sec, .card-section {
    background: var(--w-surface);
    border: 1px solid var(--w-border);
    border-radius: var(--w-radius-lg);
    box-shadow: var(--w-shadow);
    margin-bottom: 14px;
    overflow: hidden;
}
.card-section { padding: 16px; }
.card-section h6 {
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--w-muted); margin-bottom: 12px;
}
.sec-head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px 0;
}
.sec-step {
    width: 26px; height: 26px; border-radius: 50%; flex: none;
    background: var(--w-primary); color: #fff;
    font-size: 13px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}
.sec-title { font-size: 15px; font-weight: 600; margin: 0; }
.sec-title small { display: block; font-size: 12px; font-weight: 400; color: var(--w-muted); }
.sec-badge {
    margin-left: auto; background: var(--w-primary-soft); color: var(--w-primary-dark);
    border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600;
}
.sec-badge.is-empty { background: var(--w-bg); color: var(--w-muted); }
.sec-body { padding: 14px 16px 16px; }

/* ================= form controls ================= */
.form-control {
    display: block; width: 100%; box-sizing: border-box;
    font-size: 16px; color: var(--w-text);
    border: 1px solid var(--w-border-strong);
    border-radius: var(--w-radius-sm);
    padding: 11px 13px; min-height: 48px;
    background: var(--w-surface);
}
.form-control::placeholder { color: #9aa6a1; }
.form-control:focus {
    border-color: var(--w-primary); color: var(--w-text);
    box-shadow: 0 0 0 4px rgba(15, 107, 79, .14);
}
textarea.form-control { resize: vertical; line-height: 1.5; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--w-muted); display: block; margin: 0 0 6px; }
.hint { font-size: 12px; color: var(--w-muted); margin-top: 8px; }

.input-icon { position: relative; }
.input-icon > i {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--w-muted); font-size: 17px; pointer-events: none;
}
.input-icon .form-control { padding-left: 42px; }
.input-icon .form-control:focus + i, .input-icon .form-control:focus ~ i { color: var(--w-primary); }
.input-icon .toggle-pw {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 40px; height: 40px; border: none; background: none;
    color: var(--w-muted); font-size: 18px; border-radius: 8px;
}
.input-icon .toggle-pw:active { background: var(--w-bg); }
.input-icon.has-toggle .form-control { padding-right: 46px; }

/* ================= pickers (photo / video) ================= */
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    min-height: 84px; padding: 12px 8px; margin: 0;
    border: 1.5px dashed var(--w-border-strong);
    border-radius: var(--w-radius);
    background: #fafbfa; color: var(--w-muted);
    font-size: 13.5px; font-weight: 500; cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
}
.pick-tile i { font-size: 24px; color: var(--w-primary); }
.pick-tile:active, .pick-tile:hover { border-color: var(--w-primary); background: var(--w-primary-soft); color: var(--w-primary-dark); }
.pick-tile.pick-wide { flex-direction: row; gap: 10px; min-height: 64px; }
.pick-tile.pick-wide i { font-size: 22px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.photo-grid:empty { display: none; }
.photo-cell { position: relative; aspect-ratio: 1 / 1; border-radius: var(--w-radius-sm); overflow: hidden; background: var(--w-bg); border: 1px solid var(--w-border); }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del {
    position: absolute; top: 6px; right: 6px;
    width: 26px; height: 26px; border-radius: 50%; border: none; padding: 0;
    background: rgba(23, 28, 26, .72); color: #fff; font-size: 15px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.photo-del:active { background: var(--w-danger); }
@media (min-width: 480px) { .photo-grid { grid-template-columns: repeat(4, 1fr); } }

.video-preview { display: none; margin-top: 12px; }
.video-preview.show { display: block; }
.video-preview video { width: 100%; max-height: 260px; background: #000; border-radius: var(--w-radius-sm); display: block; }
.video-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--w-muted); }
.video-meta span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-ghost {
    border: 1px solid var(--w-border-strong); background: var(--w-surface); color: var(--w-text);
    border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 500; line-height: 1.3;
}
.btn-ghost.danger { color: var(--w-danger); }
.btn-ghost:active { background: var(--w-bg); }

/* ================= item rows ================= */
.item-card {
    display: flex; gap: 12px; align-items: stretch;
    border: 1px solid var(--w-border); border-radius: var(--w-radius);
    padding: 12px; margin-bottom: 10px; background: var(--w-surface);
}
.item-photo {
    position: relative; flex: none; width: 104px; height: 104px; margin: 0; cursor: pointer;
    border: 1.5px dashed var(--w-border-strong); border-radius: var(--w-radius-sm);
    background: #fafbfa; overflow: hidden;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    color: var(--w-muted); font-size: 11.5px; font-weight: 500; text-align: center;
    transition: border-color .15s, background .15s;
}
.item-photo i { font-size: 26px; color: var(--w-primary); }
.item-photo:active { border-color: var(--w-primary); background: var(--w-primary-soft); }
.item-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.item-photo .item-photo-change {
    position: absolute; left: 0; right: 0; bottom: 0; display: none;
    background: rgba(23, 28, 26, .7); color: #fff; font-size: 11px; padding: 3px 0;
}
.item-photo.has-file { border-style: solid; border-color: var(--w-primary); }
.item-photo.has-file img, .item-photo.has-file .item-photo-change { display: block; }
.item-photo.has-file i, .item-photo.has-file .item-photo-text { display: none; }

.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.item-title { font-weight: 600; font-size: 14.5px; }
.item-status { font-size: 12px; color: var(--w-muted); }
.item-status.ok { color: var(--w-primary); }
.item-remove {
    width: 34px; height: 34px; border: none; background: none; border-radius: 8px;
    color: var(--w-muted); font-size: 18px; display: inline-flex; align-items: center; justify-content: center;
    margin-right: -6px;
}
.item-remove:active { background: var(--w-danger-soft); color: var(--w-danger); }
.item-qty-label { font-size: 12px; color: var(--w-muted); margin-top: auto; margin-bottom: 4px; }

.qty-stepper { display: flex; align-items: stretch; height: 44px; }
.qty-stepper button {
    width: 44px; flex: none; font-size: 20px; font-weight: 600; padding: 0;
    border: 1px solid var(--w-border-strong); background: var(--w-surface); color: var(--w-primary-dark);
}
.qty-stepper button:active { background: var(--w-primary-soft); }
.qty-stepper button:first-child { border-radius: var(--w-radius-sm) 0 0 var(--w-radius-sm); }
.qty-stepper button:last-child { border-radius: 0 var(--w-radius-sm) var(--w-radius-sm) 0; }
.qty-stepper input {
    flex: 1; min-width: 0; width: 60px; text-align: center; font-size: 17px; font-weight: 700;
    border: 1px solid var(--w-border-strong); border-left: none; border-right: none;
    border-radius: 0; padding: 0; min-height: 0; -moz-appearance: textfield;
}
.qty-stepper input::-webkit-outer-spin-button, .qty-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-stepper input:focus { box-shadow: none; border-color: var(--w-primary); }

.btn-add-row {
    width: 100%; min-height: 48px; font-size: 15px; font-weight: 600;
    border: 1.5px dashed var(--w-primary-soft-border);
    background: var(--w-primary-soft); color: var(--w-primary-dark);
    border-radius: var(--w-radius-sm);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-add-row:active { background: #d5ecdf; }

/* ================= action bar ================= */
.action-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1010;
    background: rgba(255, 255, 255, .94); backdrop-filter: blur(10px);
    border-top: 1px solid var(--w-border); box-shadow: var(--w-shadow-up);
    padding: 10px 16px calc(10px + var(--w-safe-b));
}
.action-bar-inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 14px; }
.action-summary { flex: 1; min-width: 0; line-height: 1.25; }
.action-summary small { display: block; font-size: 11.5px; color: var(--w-muted); }
.action-summary b { font-size: 15px; font-weight: 700; }
.action-bar .btn-save { flex: none; width: auto; min-width: 150px; padding: 0 22px; }

/* ================= buttons ================= */
.btn-save {
    width: 100%; min-height: 50px; font-size: 16px; font-weight: 600;
    border: none; border-radius: var(--w-radius);
    background: var(--w-primary); color: #fff;
    box-shadow: 0 4px 14px rgba(15, 107, 79, .28);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    transition: background .15s, transform .05s;
}
.btn-save:active { background: var(--w-primary-dark); transform: translateY(1px); }
.btn-save:disabled { background: #93c2ae; box-shadow: none; }
.btn-save .spinner-border { width: 18px; height: 18px; border-width: 2px; }

/* ================= bottom-sheet modal ================= */
.modal.sheet .modal-dialog {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 520px; width: 100%;
    transform: translateY(100%); transition: transform .25s ease-out;
}
.modal.sheet.show .modal-dialog { transform: translateY(0); }
.modal.sheet .modal-content {
    border: none; border-radius: 20px 20px 0 0; padding: 8px 20px calc(20px + var(--w-safe-b));
}
.modal.sheet .sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--w-border-strong); margin: 4px auto 16px; }
.modal.sheet h5 { font-size: 17px; font-weight: 700; margin: 0 0 4px; }
.modal.sheet p { color: var(--w-muted); font-size: 14px; margin: 0 0 16px; }
.sheet-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.sheet-stat { background: var(--w-bg); border-radius: var(--w-radius-sm); padding: 10px 8px; text-align: center; }
.sheet-stat b { display: block; font-size: 20px; font-weight: 700; color: var(--w-primary-dark); line-height: 1.1; }
.sheet-stat span { font-size: 11.5px; color: var(--w-muted); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.btn-cancel {
    min-height: 50px; border-radius: var(--w-radius); font-size: 15px; font-weight: 600;
    border: 1px solid var(--w-border-strong); background: var(--w-surface); color: var(--w-text);
}
.btn-cancel:active { background: var(--w-bg); }
@media (min-width: 576px) {
    .modal.sheet .modal-dialog { bottom: auto; top: 50%; transform: translateY(-40%); opacity: 0; transition: opacity .2s, transform .2s; }
    .modal.sheet.show .modal-dialog { transform: translateY(-50%); opacity: 1; }
    .modal.sheet .modal-content { border-radius: 20px; padding-bottom: 20px; }
}

/* ================= list / view ================= */
.pi-card {
    display: block; background: var(--w-surface);
    border: 1px solid var(--w-border); border-radius: var(--w-radius-lg);
    padding: 14px 16px; margin-bottom: 12px; color: var(--w-text); text-decoration: none;
    box-shadow: var(--w-shadow);
}
.pi-card:hover { border-color: var(--w-primary); text-decoration: none; color: var(--w-text); }
.pi-sender { font-weight: 600; font-size: 15px; white-space: pre-line; }
.pi-meta { font-size: 12px; color: var(--w-muted); margin-top: 8px; }
.pi-badge {
    display: inline-block; background: var(--w-primary-soft); color: var(--w-primary-dark);
    border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600;
}
.thumb-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb-wrap { position: relative; width: 76px; height: 76px; }
.thumb-img, .thumb-wrap img {
    width: 76px; height: 76px; object-fit: cover;
    border-radius: var(--w-radius-sm); border: 1px solid var(--w-border); display: block;
}
.pit-row { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--w-border); padding: 10px 0; }
.pit-row:last-child { border-bottom: none; }
.pit-row img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--w-radius-sm); border: 1px solid var(--w-border); }
.pit-qty { font-size: 16px; font-weight: 700; color: var(--w-primary-dark); }
.pit-label { font-size: 13px; color: var(--w-muted); }
.empty-state { text-align: center; color: var(--w-muted); padding: 40px 10px; font-size: 14px; }
.pre-line { white-space: pre-line; }
.video-embed { width: 100%; border-radius: var(--w-radius-sm); display: block; }

/* ================= login ================= */
body.login-body { background: var(--w-bg); min-height: 100vh; min-height: 100dvh; }
.login-hero {
    background: var(--w-primary-gradient);
    padding: calc(40px + env(safe-area-inset-top, 0px)) 24px 80px;
    color: #fff; text-align: center; position: relative; overflow: hidden;
}
.login-hero::before, .login-hero::after {
    content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .06);
}
.login-hero::before { width: 280px; height: 280px; top: -120px; right: -90px; }
.login-hero::after { width: 200px; height: 200px; bottom: -110px; left: -70px; }
.login-logo {
    width: 68px; height: 68px; border-radius: 20px; margin: 0 auto 14px;
    background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .25);
    display: flex; align-items: center; justify-content: center; font-size: 32px;
    position: relative; backdrop-filter: blur(6px);
}
.login-hero h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.01em; position: relative; }
.login-hero p { margin: 4px 0 0; font-size: 13.5px; opacity: .85; position: relative; }
.login-card-wrap { max-width: 420px; margin: -52px auto 0; padding: 0 16px 32px; position: relative; }
.login-card {
    background: var(--w-surface); border: 1px solid var(--w-border);
    border-radius: 20px; box-shadow: 0 10px 34px rgba(15, 23, 20, .12); padding: 26px 22px 22px;
}
.login-card h2 { font-size: 17px; font-weight: 700; margin: 0 0 2px; }
.login-card .sub { font-size: 13px; color: var(--w-muted); margin-bottom: 18px; }
.login-card .field-label { margin-top: 12px; }
.login-card .btn-save { margin-top: 20px; }
.login-foot { text-align: center; font-size: 12px; color: var(--w-muted); margin-top: 22px; }
@media (min-width: 768px) {
    .login-hero { padding-top: 80px; padding-bottom: 96px; }
}

/* ================= alerts ================= */
.alert {
    border-radius: var(--w-radius-sm); font-size: 14px; padding: 11px 14px;
    border: 1px solid transparent; display: flex; align-items: flex-start; gap: 9px; margin-bottom: 14px;
}
.alert i { font-size: 17px; line-height: 1.3; }
.alert-danger { background: var(--w-danger-soft); color: #b42318; border-color: var(--w-danger-border); }
.alert-success { background: var(--w-primary-soft); color: var(--w-primary-dark); border-color: var(--w-primary-soft-border); }
