/* =========================================================
   1000 Micro Niche — Design System
   Mobile-first, modern & interaktif
   ========================================================= */

:root {
    --primary: #16a34a;
    --primary-dark: #15803d;
    --primary-light: #22c55e;
    --primary-50: #f0fdf4;
    --primary-100: #dcfce7;
    --accent: #7c3aed;
    --bg: #f6f8f7;
    --bg-soft: #eef2f0;
    --card-bg: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --muted-2: #9ca3af;
    --border: #e7eaee;
    --danger: #dc2626;
    --danger-50: #fef2f2;
    --info: #2563eb;
    --warning: #d97706;
    --success: #16a34a;
    --radius-sm: 9px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 2px 6px rgba(16, 24, 40, .06);
    --shadow-md: 0 10px 24px -8px rgba(16, 24, 40, .16);
    --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .22);
    --topbar-h: 58px;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
    background:
        radial-gradient(1200px 400px at 50% -120px, var(--primary-50), transparent 60%),
        var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

img { max-width: 100%; display: block; }

::selection { background: var(--primary-100); color: var(--primary-dark); }

/* Scrollbar (webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #b9c0ca; }

.container { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* ===== TOPBAR ===== */
.topbar {
    background: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
    padding-top: var(--safe-t);
}
.topbar-inner { display: flex; justify-content: space-between; align-items: center; height: var(--topbar-h); gap: 12px; }
.brand {
    font-weight: 800; color: var(--primary-dark); text-decoration: none; font-size: 17px;
    letter-spacing: -.01em; display: flex; align-items: center; gap: 8px;
}
.brand::before {
    content: "";
    width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
    box-shadow: var(--shadow-sm);
}
.btn-link {
    color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 600;
    padding: 8px 12px; border-radius: 99px; transition: background .15s, color .15s;
}
.btn-link:hover, .btn-link:active { background: #f3f4f6; color: var(--text); }

main.container { padding-top: 22px; padding-bottom: calc(56px + var(--safe-b)); min-height: calc(100vh - 160px); }

.footer { text-align: center; color: var(--muted-2); font-size: 12.5px; padding: 28px 0 calc(20px + var(--safe-b)); }

/* ===== ALERTS ===== */
.alert {
    padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px;
    font-weight: 600; border: 1px solid transparent; display: flex; align-items: center; gap: 10px;
    animation: slideDown .25s ease;
}
.alert::before { font-size: 16px; line-height: 1; }
.alert-danger { background: var(--danger-50); color: #991b1b; border-color: #fecaca; }
.alert-danger::before { content: "⚠"; }
.alert-success { background: var(--primary-50); color: #166534; border-color: #bbf7d0; }
.alert-success::before { content: "✓"; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-warning::before { content: "!"; }

@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }

/* ===== AUTH CARD ===== */
.auth-card {
    max-width: 400px;
    margin: 8vh auto;
    background: var(--card-bg);
    padding: 34px 26px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    text-align: center;
    box-shadow: var(--shadow-md);
    animation: popIn .35s ease;
}
.auth-card h1 { font-size: 21px; margin-bottom: 4px; letter-spacing: -.01em; }
.muted { color: var(--muted); font-size: 14px; }

form label { display: block; text-align: left; font-size: 13px; margin: 16px 0 6px; font-weight: 700; color: #374151; }
input[type="text"], input[type="password"], input[type="date"] {
    width: 100%; padding: 12px 14px; border: 1.5px solid var(--border);
    border-radius: 10px; font-size: 15px; text-transform: uppercase;
    background: #fafafa; transition: border-color .15s, box-shadow .15s, background .15s;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="date"]:focus {
    outline: none; border-color: var(--primary); background: #fff;
    box-shadow: 0 0 0 4px var(--primary-100);
}
input[type="password"] { text-transform: none; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: none; border-radius: 10px; padding: 12px 20px;
    font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none;
    transition: transform .12s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
    -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-primary {
    background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
    color: #fff; box-shadow: 0 4px 14px -4px rgba(21, 128, 61, .55);
}
.btn-primary:hover { box-shadow: 0 6px 18px -4px rgba(21, 128, 61, .65); filter: brightness(1.03); }
.btn-block { width: 100%; margin-top: 18px; min-height: 48px; }

/* ===== STEP HEADER ===== */
.step-header { margin-bottom: 22px; animation: fadeUp .3s ease; }
.step-badge {
    display: inline-flex; align-items: center; gap: 6px; background: var(--primary-100); color: var(--primary-dark);
    font-size: 12px; font-weight: 800; padding: 5px 12px; border-radius: 999px; margin-bottom: 10px;
    letter-spacing: .02em;
}
.step-badge::before { content: "●"; font-size: 8px; color: var(--primary); }
.back-link {
    display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none;
    font-size: 13px; font-weight: 600; margin-bottom: 8px; padding: 4px 0; transition: color .15s, gap .15s;
}
.back-link:hover { color: var(--primary-dark); gap: 7px; }
.step-header h1 { margin: 4px 0 6px; font-size: 23px; letter-spacing: -.02em; line-height: 1.25; }

/* ===== CARD GRIDS (Kategori / Micro / Nano) ===== */
.grid-cards {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px;
}
.card-item {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; text-decoration: none; color: var(--text);
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    transition: border-color .15s, transform .15s, box-shadow .15s;
    box-shadow: var(--shadow-xs);
    animation: fadeUp .35s ease both;
    -webkit-tap-highlight-color: transparent;
}
.grid-cards .card-item:nth-child(1) { animation-delay: .02s; }
.grid-cards .card-item:nth-child(2) { animation-delay: .05s; }
.grid-cards .card-item:nth-child(3) { animation-delay: .08s; }
.grid-cards .card-item:nth-child(4) { animation-delay: .11s; }
.grid-cards .card-item:nth-child(5) { animation-delay: .14s; }
.grid-cards .card-item:nth-child(6) { animation-delay: .17s; }
.grid-cards .card-item:nth-child(n+7) { animation-delay: .2s; }
.card-item:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card-item:active { transform: translateY(0) scale(.985); }
.card-item-title { font-weight: 700; font-size: 15px; line-height: 1.35; }
.card-item-arrow {
    color: var(--primary); font-size: 15px; flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary-50); display: flex; align-items: center; justify-content: center;
    transition: background .15s, transform .15s;
}
.card-item:hover .card-item-arrow { background: var(--primary); color: #fff; transform: translateX(2px); }

/* ===== PRODUCT GRID ===== */
.grid-produk {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px;
}
.produk-card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; display: flex; flex-direction: column; gap: 9px;
    box-shadow: var(--shadow-xs); transition: box-shadow .2s, transform .2s;
    animation: fadeUp .35s ease both;
}
.grid-produk .produk-card:nth-child(1) { animation-delay: .02s; }
.grid-produk .produk-card:nth-child(2) { animation-delay: .05s; }
.grid-produk .produk-card:nth-child(3) { animation-delay: .08s; }
.grid-produk .produk-card:nth-child(4) { animation-delay: .11s; }
.grid-produk .produk-card:nth-child(5) { animation-delay: .14s; }
.grid-produk .produk-card:nth-child(6) { animation-delay: .17s; }
.grid-produk .produk-card:nth-child(n+7) { animation-delay: .2s; }
.produk-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.produk-judul { font-weight: 800; font-size: 15.5px; line-height: 1.4; }
.produk-meta { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.produk-meta::before { content: "▸"; color: var(--muted-2); font-size: 11px; }
.produk-harga {
    font-size: 14px; font-weight: 800; color: var(--primary-dark);
    background: var(--primary-50); padding: 5px 10px; border-radius: 8px; width: fit-content;
}
.produk-deskripsi {
    font-size: 13.5px; color: var(--muted); margin: 0; line-height: 1.55;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.btn-copy {
    margin-top: 4px; background: #f5f3ff; color: #5b21b6; border: 1.5px solid #ede9fe;
    border-radius: 10px; padding: 11px 14px; font-size: 13.5px; font-weight: 700; cursor: pointer;
    transition: background .15s, transform .12s, border-color .15s; display: flex; align-items: center; justify-content: center; gap: 6px;
    -webkit-tap-highlight-color: transparent;
}
.btn-copy::before { content: "⧉"; font-size: 14px; }
.btn-copy:hover { background: #ede9fe; border-color: #ddd6fe; }
.btn-copy:active { transform: scale(.97); }
.btn-copy-done { background: var(--primary-100) !important; color: #166534 !important; border-color: #bbf7d0 !important; }
.btn-copy-done::before { content: "✓" !important; }

.badge {
    display: inline-flex; align-items: center; font-size: 11px; font-weight: 800; padding: 4px 10px;
    border-radius: 999px; width: fit-content; letter-spacing: .01em;
}
.badge-success { background: var(--primary-100); color: #166534; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }

.empty-state {
    background: var(--card-bg); border: 1.5px dashed var(--border); border-radius: var(--radius-lg);
    padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14.5px;
}
.empty-state::before {
    content: "🔍"; display: block; font-size: 30px; margin-bottom: 10px; opacity: .6;
}

/* Toast (copy feedback, optional use) */
.toast {
    position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
    background: #111827; color: #fff; padding: 11px 18px; border-radius: 99px; font-size: 13.5px; font-weight: 600;
    box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =========================================================
   ADMIN
   ========================================================= */
.admin-body { background: var(--bg); }
.admin-shell { display: flex; min-height: 100vh; }

.admin-topbar-mobile {
    display: none;
    position: sticky; top: 0; z-index: 50;
    padding-top: var(--safe-t);
    background: rgba(17, 24, 39, .96); backdrop-filter: blur(8px);
    align-items: center; justify-content: space-between; height: var(--topbar-h); padding-left: 14px; padding-right: 14px;
    color: #fff; box-shadow: var(--shadow-sm);
}
.admin-topbar-mobile .brand { color: #fff; font-size: 15px; }
.menu-toggle {
    background: rgba(255,255,255,.1); border: none; width: 38px; height: 38px; border-radius: 9px;
    color: #fff; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.menu-toggle:hover { background: rgba(255,255,255,.18); }

.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 55; opacity: 0;
    transition: opacity .2s;
}
.sidebar-overlay.show { display: block; opacity: 1; }

.admin-sidebar {
    width: 226px; background: linear-gradient(180deg, #111827, #0b1120); color: #d1d5db; flex-shrink: 0; padding: 22px 0;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-sidebar .brand {
    color: #fff; padding: 0 20px 20px; display: flex; align-items: center; gap: 8px; font-size: 15.5px; font-weight: 800;
}
.admin-sidebar .brand::before {
    content: ""; width: 24px; height: 24px; border-radius: 7px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary-dark)); flex-shrink: 0;
}
.admin-sidebar a {
    display: flex; align-items: center; gap: 10px; padding: 11px 20px; color: #9ca3af; text-decoration: none; font-size: 14px;
    font-weight: 600; border-left: 3px solid transparent; transition: background .15s, color .15s, border-color .15s;
}
.admin-sidebar a:hover { background: rgba(255,255,255,.05); color: #fff; }
.admin-sidebar a.active { background: rgba(22, 163, 74, .15); color: #fff; border-left-color: var(--primary-light); }

.admin-main { flex: 1; padding: 26px; max-width: 100%; overflow-x: hidden; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 10px; }
.admin-topbar h1 { font-size: 21px; margin: 0; letter-spacing: -.01em; }

/* Table: horizontal-scroll wrapper w/ sticky header, mobile-friendly */
table.admin-table {
    width: 100%; border-collapse: collapse; background: var(--card-bg); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow-xs); border: 1px solid var(--border);
}
.admin-table-wrap {
    overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow-xs);
    -webkit-overflow-scrolling: touch; border: 1px solid var(--border); background: var(--card-bg);
}
.admin-table-wrap table.admin-table { box-shadow: none; border: none; min-width: 640px; }
table.admin-table th, table.admin-table td {
    text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; white-space: nowrap;
}
table.admin-table td { white-space: normal; }
table.admin-table th {
    background: #f9fafb; font-weight: 800; color: var(--muted); font-size: 11px; text-transform: uppercase;
    letter-spacing: .04em; position: sticky; top: 0;
}
table.admin-table tr { transition: background .12s; }
table.admin-table tbody tr:hover { background: #fafbfc; }
table.admin-table tr:last-child td { border-bottom: none; }

.form-box {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 22px; max-width: 540px; margin-bottom: 22px; box-shadow: var(--shadow-xs);
}
.form-box label { display: block; font-size: 13px; font-weight: 700; margin: 13px 0 6px; color: #374151; }
.form-box input[type="text"], .form-box input[type="password"], .form-box input[type="date"],
.form-box select, .form-box textarea {
    width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 9px; font-size: 14px;
    text-transform: none; font-family: inherit; background: #fafafa; transition: border-color .15s, box-shadow .15s, background .15s;
}
.form-box select { -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.form-box input:focus, .form-box select:focus, .form-box textarea:focus {
    outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px var(--primary-100);
}
.form-box textarea { resize: vertical; min-height: 80px; }

.btn-sm { padding: 8px 13px; font-size: 12.5px; }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 3px 10px -4px rgba(220,38,38,.5); }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: #eef0f2; color: #111827; box-shadow: none; }
.btn-secondary:hover { background: #e2e5e9; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); box-shadow: none; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-50); }

.actions-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }

code.kode-akses {
    background: #f3f4f6; padding: 4px 9px; border-radius: 7px; font-weight: 800; letter-spacing: 1px; font-size: 13px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 899px) {
    .admin-sidebar {
        position: fixed; top: 0; left: 0; height: 100dvh; z-index: 60; transform: translateX(-100%);
        transition: transform .25s ease; padding-top: calc(22px + var(--safe-t)); box-shadow: var(--shadow-lg);
    }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-topbar-mobile { display: flex; }
    .admin-main { padding: 18px 14px 40px; }
    .admin-shell { display: block; }
}

@media (max-width: 640px) {
    .container { padding: 0 14px; }
    .grid-cards { grid-template-columns: 1fr; }
    .grid-produk { grid-template-columns: 1fr; }
    .step-header h1 { font-size: 20px; }
    .auth-card { margin: 6vh auto; padding: 28px 20px; }
    .admin-topbar h1 { font-size: 18px; }
    .form-box { padding: 18px; }
    .btn { min-height: 44px; }
}

@media (min-width: 641px) and (max-width: 899px) {
    .grid-cards { grid-template-columns: repeat(2, 1fr); }
    .grid-produk { grid-template-columns: repeat(2, 1fr); }
}
