/* =========================================================
   Manajemen Stok — style.css
   Konsep: konsol operasional yang tenang & profesional.
   ========================================================= */

:root {
    --bg:        #eef1f5;
    --surface:   #ffffff;
    --ink:       #1a2233;
    --muted:     #6b7688;
    --line:      #e4e8ee;
    --line-soft: #eef1f5;

    --primary:      #0d9488;   /* teal */
    --primary-dark: #0b7d73;
    --primary-soft: #e3f5f2;

    --sidebar:      #17212f;   /* ink gelap */
    --sidebar-2:    #1e2a3a;
    --sidebar-txt:  #aeb9c8;
    --sidebar-actv: #0d9488;

    --amber:      #f0a800;
    --amber-soft: #fff6e0;

    --danger:     #dc2626;
    --danger-soft:#fdecec;
    --green:      #16a34a;
    --blue:       #2563eb;

    --radius:  10px;
    --radius-s: 7px;
    --shadow: 0 1px 2px rgba(20,30,50,.06), 0 4px 14px rgba(20,30,50,.05);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Layout kerangka ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 244px;
    flex-shrink: 0;
    background: var(--sidebar);
    color: var(--sidebar-txt);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 20px 16px;
    color: #fff;
    font-weight: 700;
    letter-spacing: .2px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.logo-mark {
    display: inline-grid; place-items: center;
    width: 30px; height: 30px;
    background: var(--primary);
    color: #fff; border-radius: 8px;
    font-size: 16px;
}
.brand-name { font-size: 15px; }

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px;
    color: var(--sidebar-txt);
    text-decoration: none;
    border-radius: var(--radius-s);
    font-weight: 500;
    transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.active { background: var(--sidebar-actv); color: #fff; }
.nav-ico { width: 18px; text-align: center; font-size: 15px; opacity: .95; }
.nav-sep {
    margin: 14px 12px 6px;
    font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
    color: #5d6a7c;
}

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.07); }
.who { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.who-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: grid; place-items: center; font-weight: 700;
}
.who-name { color: #fff; font-weight: 600; font-size: 13.5px; }
.who-role { font-size: 12px; color: #7c8798; }

/* Tombol Keluar di dalam sidebar gelap */
.sidebar-foot .btn-ghost {
    color: #d3dbe6;
    border-color: rgba(255,255,255,.16);
    background: rgba(255,255,255,.05);
}
.sidebar-foot .btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }

.content { flex: 1; min-width: 0; padding: 26px 30px 46px; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; margin-bottom: 22px;
}
.topbar-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.2px; }
.topbar-sub { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }
.topbar-actions { flex-shrink: 0; }

/* ---------- Hero nilai inventori ---------- */
.hero {
    background: linear-gradient(120deg, #12303a 0%, #0d9488 130%);
    color: #fff;
    border-radius: 14px;
    padding: 26px 28px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 24px; flex-wrap: wrap;
    margin-bottom: 28px;
    box-shadow: var(--shadow);
}
.hero-label { display: block; font-size: 13px; opacity: .8; margin-bottom: 8px; }
.hero-value {
    display: block; font-size: 40px; font-weight: 750; letter-spacing: -.5px;
    font-variant-numeric: tabular-nums; line-height: 1.05;
}
.hero-note { display: block; font-size: 12.5px; opacity: .72; margin-top: 8px; }
.hero-stats { display: flex; gap: 14px; }
.hero-stat {
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 10px; padding: 14px 18px; min-width: 118px; text-align: center;
}
.hs-num { display: block; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hs-lbl { display: block; font-size: 12px; opacity: .82; margin-top: 2px; }

/* ---------- Section ---------- */
.section-title { font-size: 15px; font-weight: 700; margin: 24px 0 12px; }
.section-title.mb0 { margin-bottom: 0; }
.section-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; margin: 26px 0 12px; flex-wrap: wrap;
}
.empty { color: var(--muted); font-size: 13.5px; }

/* ---------- Card grid (kategori / tipe) ---------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    padding: 15px 16px;
    box-shadow: var(--shadow);
}
.stat-card.alt { border-left-color: var(--amber); }
.sc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.sc-name { font-weight: 600; font-size: 14px; }
.sc-badge {
    font-size: 11.5px; color: var(--muted);
    background: var(--line-soft); padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.sc-big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sc-unit { font-size: 12px; font-weight: 500; color: var(--muted); }

/* ---------- Search & pill ---------- */
.search-box { position: relative; }
.search-box input {
    width: 300px; max-width: 60vw;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    background: var(--surface); font-size: 13.5px; color: var(--ink);
}
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.count-pill {
    background: var(--surface); border: 1px solid var(--line);
    padding: 6px 13px; border-radius: 20px; font-size: 13px; font-weight: 600; color: var(--muted);
}

/* ---------- Tabel ---------- */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: var(--shadow);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table thead th {
    text-align: left;
    padding: 12px 16px;
    background: #f7f9fb;
    color: var(--muted);
    font-weight: 600; font-size: 12px;
    letter-spacing: .3px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover:not(.no-hover) { background: #f9fbfc; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table th.num { text-align: right; }
.data-table .strong { font-weight: 700; }
.data-table .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12.5px; color: #35507a; }
.data-table .nowrap { white-space: nowrap; }
.unit-sm { color: var(--muted); font-size: 11.5px; }
.act-col { text-align: right; white-space: nowrap; width: 96px; }
.empty-row { text-align: center; color: var(--muted); padding: 30px 16px !important; }
.search-empty { color: var(--muted); font-size: 13.5px; margin-top: 12px; text-align: center; }

/* baris barang terbaru / baru ditambah */
.row-new, .flash-new { background: var(--amber-soft) !important; box-shadow: inset 3px 0 0 var(--amber); }
@keyframes flashFade { from { background: #fff2ca; } to { background: transparent; } }
.flash-anim td { animation: flashFade 2.6s ease-out; }

/* ---------- Tag & badge ---------- */
.tag {
    display: inline-block; padding: 2px 9px; border-radius: 5px;
    background: var(--line-soft); color: #48566b; font-size: 12px; font-weight: 500;
}
.tag-admin { background: var(--primary-soft); color: var(--primary-dark); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 5px; font-size: 12px; font-weight: 600; }
.b-blue  { background: #e6efff; color: #1d4ed8; }
.b-grey  { background: #eef1f5; color: #556; }
.b-green { background: #e4f7ea; color: #147a37; }
.b-amber { background: #fff2d6; color: #9a6a00; }
.b-red   { background: var(--danger-soft); color: #b91c1c; }
.b-teal  { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- Tombol ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: var(--radius-s);
    font-size: 13.5px; font-weight: 600; font-family: inherit;
    border: 1px solid transparent; cursor: pointer;
    transition: background .12s, border-color .12s, opacity .12s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--line-soft); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }

.btn-icon {
    width: 32px; height: 32px; border-radius: 6px;
    border: 1px solid var(--line); background: var(--surface); cursor: pointer;
    font-size: 14px; color: #45536a; margin-left: 4px;
    transition: background .12s, border-color .12s, color .12s;
}
.btn-icon:hover { background: var(--line-soft); }
.btn-icon.danger:hover { background: var(--danger-soft); border-color: #f3b4b4; color: var(--danger); }

.muted-sm { color: var(--muted); }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(20,28,42,.5);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 48px 16px; z-index: 100;
    backdrop-filter: blur(1px);
}
/* atribut hidden HTML harus menang atas display:flex di atas */
.modal-overlay[hidden] { display: none; }
.modal {
    background: var(--surface); border-radius: 12px; width: 560px; max-width: 100%;
    box-shadow: 0 20px 50px rgba(15,23,40,.28);
    animation: modalIn .16s ease-out;
}
.modal-sm { width: 420px; }
@keyframes modalIn { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: none; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Form ---------- */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.field { margin-bottom: 14px; display: flex; flex-direction: column; }
.field label { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: #3b4757; }
.field .opt { color: var(--muted); font-weight: 400; }
.field input, .field select, .field textarea {
    padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-s);
    font-size: 14px; font-family: inherit; color: var(--ink); background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.field textarea { resize: vertical; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }

/* ---------- Alert / toast ---------- */
.alert { padding: 11px 14px; border-radius: var(--radius-s); font-size: 13.5px; margin-bottom: 16px; }
.alert-error { background: var(--danger-soft); color: #b91c1c; border: 1px solid #f4c4c4; }

#toastWrap { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: #12303a; color: #fff; padding: 12px 16px; border-radius: 8px;
    font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.2);
    animation: toastIn .2s ease-out; max-width: 340px;
}
.toast.ok  { background: #0d7a4f; }
.toast.err { background: #b3261e; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Login ---------- */
.login-page {
    display: grid; place-items: center; min-height: 100vh;
    background: linear-gradient(135deg, #17212f 0%, #0d9488 160%);
    padding: 20px;
}
.login-card {
    background: var(--surface); width: 380px; max-width: 100%;
    border-radius: 14px; padding: 30px 28px;
    box-shadow: 0 24px 60px rgba(10,18,32,.35);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand h1 { margin: 0; font-size: 19px; }
.login-brand p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.login-card .logo-mark { width: 40px; height: 40px; font-size: 20px; }
.login-card label { display: block; font-size: 12.5px; font-weight: 600; margin: 12px 0 6px; color: #3b4757; }
.login-card input {
    width: 100%; padding: 11px 13px; border: 1px solid var(--line);
    border-radius: var(--radius-s); font-size: 14.5px; font-family: inherit;
}
.login-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.login-card .btn-block { margin-top: 18px; padding: 11px; }
.login-hint { text-align: center; font-size: 12.5px; color: var(--muted); margin: 18px 0 0; }

/* ---------- Responsif ---------- */
@media (max-width: 860px) {
    .app { flex-direction: column; }
    .sidebar {
        width: 100%; height: auto; position: static; flex-direction: row;
        align-items: center; flex-wrap: wrap;
    }
    .brand { border-bottom: none; padding: 14px 16px; }
    .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; padding: 0 12px 12px; }
    .nav-sep { display: none; }
    .sidebar-foot { border-top: none; display: flex; align-items: center; gap: 12px; padding: 0 16px 12px; }
    .who { margin-bottom: 0; }
    .content { padding: 20px 16px 40px; }
    .hero-value { font-size: 32px; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .search-box input { width: 100%; max-width: 100%; }
    .section-head { align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
