/* ==========================================================================
   Theme — shared design system
   Warm cream/terracotta palette, serif display, soft motion.
   Dipakai sebagai base untuk semua halaman aplikasi.
   ========================================================================== */

/* ===== Design tokens ===== */
:root {
    --bg: #faf9f5;
    --bg-subtle: #f5f4ed;
    --surface: #ffffff;
    --surface-hover: #f8f7f2;
    --border: #e8e5da;
    --border-strong: #d4d0c0;
    --text: #1f1e1d;
    --text-muted: #6b6660;
    --text-subtle: #9a948a;
    --accent: #c15f3c;
    --accent-hover: #a54d2d;
    --accent-soft: #f3e4dc;
    --accent-ring: rgba(193, 95, 60, 0.18);
    --danger: #b94b3d;
    --danger-soft: #fceae6;
    --warning: #b58537;
    --warning-soft: #fbf1df;
    --success: #5b8a5e;
    --success-soft: #e4efe1;
    --info: #4a6f8d;
    --info-soft: #e2ecf3;
    --shadow-sm: 0 1px 2px rgba(31, 30, 29, 0.04);
    --shadow-md: 0 4px 12px rgba(31, 30, 29, 0.06), 0 1px 2px rgba(31, 30, 29, 0.04);
    --shadow-lg: 0 12px 32px rgba(31, 30, 29, 0.08), 0 2px 4px rgba(31, 30, 29, 0.04);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --t-fast: 0.14s;
    --t-base: 0.2s;
    --t-slow: 0.35s;
    --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

[data-theme="dark"] {
    --bg: #1f1e1d;
    --bg-subtle: #26231f;
    --surface: #2a2724;
    --surface-hover: #332f2b;
    --border: #3a3631;
    --border-strong: #4a453f;
    --text: #f5f1ea;
    --text-muted: #b3ab9f;
    --text-subtle: #807a70;
    --accent: #da7756;
    --accent-hover: #c15f3c;
    --accent-soft: #3a2a22;
    --accent-ring: rgba(218, 119, 86, 0.22);
    --danger: #e08272;
    --danger-soft: #3a2320;
    --warning: #d4a86a;
    --warning-soft: #3a2e1e;
    --success: #87b58b;
    --success-soft: #243024;
    --info: #8eb3cf;
    --info-soft: #1e2b35;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.25);
}

/* ===== Reset & base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--t-slow) ease, color var(--t-base) ease;
}

/* Typography utility */
.serif {
    font-family: 'Instrument Serif', 'Times New Roman', serif;
    font-weight: 400;
    letter-spacing: -0.01em;
}
.mono {
    font-family: ui-monospace, 'SF Mono', 'Menlo', 'Consolas', monospace;
}

/* Decorative radial glow — opt-in via .has-glow on <body> */
body.has-glow::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.45;
    background-image:
        radial-gradient(circle at 20% 10%, rgba(193, 95, 60, 0.06) 0%, transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(193, 95, 60, 0.05) 0%, transparent 50%);
}
[data-theme="dark"] body.has-glow::before {
    background-image:
        radial-gradient(circle at 20% 10%, rgba(218, 119, 86, 0.09) 0%, transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(218, 119, 86, 0.06) 0%, transparent 50%);
}

/* Links */
a { color: var(--accent); text-decoration: none; transition: color var(--t-base) ease; }
a:hover { color: var(--accent-hover); }

/* ===== Brand mark (logo square) ===== */
.brand {
    display: inline-flex; align-items: center; gap: 10px;
    font-weight: 600; font-size: 15px;
    color: var(--text); text-decoration: none;
}
.brand:hover { color: var(--text); }
.brand-dot {
    width: 26px; height: 26px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #d97b5a);
    box-shadow: 0 1px 3px rgba(193, 95, 60, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    position: relative;
    flex-shrink: 0;
}
.brand-dot::after {
    content: '';
    position: absolute; inset: 5px;
    border-radius: 4px;
    background: var(--bg);
    opacity: 0.9;
}
.brand-dot.lg { width: 44px; height: 44px; border-radius: 12px; }
.brand-dot.lg::after { inset: 8px; border-radius: 6px; }

/* ===== Nav (sticky top bar) ===== */
.nav {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: saturate(140%) blur(12px);
    -webkit-backdrop-filter: saturate(140%) blur(12px);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    border-bottom: 1px solid var(--border);
}
.nav-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-links { display: flex; gap: 6px; align-items: center; }
.nav-link {
    padding: 8px 12px;
    font-size: 13.5px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--t-base) ease;
}
.nav-link:hover { color: var(--text); background: var(--surface-hover); }
.nav-link.active { color: var(--text); background: var(--surface-hover); }

/* ===== Theme toggle ===== */
.theme-toggle {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--t-base) ease;
    padding: 0;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--border-strong); transform: translateY(-1px); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: block; }

/* ===== Card ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: all var(--t-slow) ease;
}
.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card.flat:hover { box-shadow: var(--shadow-sm); border-color: var(--border); }
.card h3 {
    margin: 0 0 4px;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.005em;
}
.card .hint {
    margin: 0 0 18px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== Form primitives ===== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field.row { flex-direction: row; justify-content: space-between; align-items: center; }

.label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}
.label .req { color: var(--accent); margin-left: 2px; }

.input, .textarea, .select {
    width: 100%;
    padding: 11px 14px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: 0;
    transition: all var(--t-fast) ease;
}
[data-theme="dark"] .input,
[data-theme="dark"] .textarea,
[data-theme="dark"] .select { background: var(--bg-subtle); }
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .textarea:focus, .select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-ring);
}
.input.error, .textarea.error, .select.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 18%, transparent);
}
.textarea { resize: vertical; min-height: 92px; line-height: 1.55; }

.helper { font-size: 12px; color: var(--text-subtle); }
.helper.error { color: var(--danger); }

/* Input with leading icon */
.input-ic { position: relative; }
.input-ic .ic {
    position: absolute; left: 13px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-subtle); pointer-events: none;
    width: 16px; height: 16px;
}
.input-ic .input { padding-left: 40px; }

/* Input with trailing action (e.g., eye toggle for password) */
.input-act { position: relative; }
.input-act .input { padding-right: 44px; }
.input-act .act {
    position: absolute; right: 8px; top: 50%;
    transform: translateY(-50%);
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent;
    border: 0;
    color: var(--text-subtle);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--t-base) ease;
}
.input-act .act:hover { color: var(--accent); background: var(--surface-hover); }
.input-act .act svg { width: 16px; height: 16px; }

/* Input group with prefix/suffix */
.input-group {
    display: flex; align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    transition: all var(--t-fast) ease;
}
[data-theme="dark"] .input-group { background: var(--bg-subtle); }
.input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.input-group .prefix,
.input-group .suffix {
    padding: 0 12px; display: flex; align-items: center;
    color: var(--text-muted); font-size: 14px;
    background: var(--bg-subtle);
}
.input-group .prefix { border-right: 1px solid var(--border); }
.input-group .suffix { border-left: 1px solid var(--border); }
.input-group .input { border: 0; border-radius: 0; box-shadow: none !important; background: transparent; }

/* Select (native, styled chevron) */
.select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 40px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'><path stroke='%239a948a' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='m6 8 4 4 4-4'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-family: inherit; font-size: 14px; font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--t-base) ease;
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(193, 95, 60, 0.3); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(193, 95, 60, 0.3); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 85%, black); color: #fff; transform: translateY(-1px); }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn svg { width: 15px; height: 15px; }

/* ===== Chips ===== */
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 11px;
    border-radius: 10px;
    font-size: 13px;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--t-fast) ease;
    font-family: inherit;
}
.chip:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
.chip.solid { background: var(--surface); border-color: var(--border); }
.chip svg { width: 15px; height: 15px; }

/* ===== Toggle switch ===== */
.switch {
    --w: 40px; --h: 22px;
    position: relative; display: inline-block;
    width: var(--w); height: var(--h);
    flex-shrink: 0;
}
.switch input { display: none; }
.switch .track {
    position: absolute; inset: 0;
    background: var(--border-strong);
    border-radius: 999px;
    cursor: pointer;
    transition: background var(--t-base) ease;
}
.switch .track::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: calc(var(--h) - 4px); height: calc(var(--h) - 4px);
    background: #fff; border-radius: 50%;
    transition: all var(--t-base) cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { left: calc(var(--w) - var(--h) + 2px); }

/* ===== Checkbox cards ===== */
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-card {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--t-fast) ease;
    background: var(--surface);
}
.check-card:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.check-card input { display: none; }
.check-card .box {
    width: 18px; height: 18px; border-radius: 5px;
    border: 1.5px solid var(--border-strong);
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0; margin-top: 1px;
    transition: all var(--t-fast) ease;
}
.check-card .box svg { width: 12px; height: 12px; color: #fff; opacity: 0; transform: scale(0.6); transition: all var(--t-base) ease; }
.check-card input:checked ~ .box {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-ring);
}
.check-card input:checked ~ .box svg { opacity: 1; transform: scale(1); }
.check-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
[data-theme="dark"] .check-card:has(input:checked) { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.check-card .meta { display: flex; flex-direction: column; }
.check-card .meta .title { font-size: 14px; font-weight: 500; color: var(--text); }
.check-card .meta .desc { font-size: 12.5px; color: var(--text-muted); }

/* ===== Segmented radio ===== */
.segment {
    display: inline-flex; padding: 4px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    gap: 2px;
}
.segment input { display: none; }
.segment label {
    padding: 7px 14px;
    font-size: 13px; font-weight: 500;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--t-base) ease;
}
.segment label:hover { color: var(--text); }
.segment input:checked + label {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* ===== Range slider ===== */
.slider-top { display: flex; justify-content: space-between; align-items: center; }
.slider-val {
    font-family: 'Instrument Serif', serif;
    font-size: 22px;
    color: var(--accent);
}
.slider-range { display: flex; justify-content: space-between; margin-top: 4px; }
input[type="range"].slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%; height: 6px;
    border-radius: 999px;
    background: var(--border);
    outline: 0;
}
input[type="range"].slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 0 4px var(--accent-ring);
    transition: transform var(--t-fast) ease;
}
input[type="range"].slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"].slider::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--accent); cursor: pointer; border: 0;
}

/* ===== File drop ===== */
.drop {
    display: block;
    border: 1.5px dashed var(--border-strong);
    background: var(--bg-subtle);
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--t-base) ease;
}
.drop:hover, .drop.drag {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-1px);
}
.drop svg { width: 28px; height: 28px; color: var(--text-muted); margin-bottom: 8px; }
.drop .main { font-size: 14px; color: var(--text); font-weight: 500; }
.drop .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.drop input { display: none; }

/* ===== Tag input ===== */
.tag-field {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: all var(--t-fast) ease;
    min-height: 44px;
}
[data-theme="dark"] .tag-field { background: var(--bg-subtle); }
.tag-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.tag {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 8px 4px 10px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 500;
    animation: popIn 0.2s ease;
}
.tag .x { cursor: pointer; opacity: 0.65; display: inline-flex; }
.tag .x:hover { opacity: 1; }
.tag-input {
    flex: 1; min-width: 100px;
    border: 0; outline: 0; background: transparent;
    font-family: inherit; font-size: 14px; color: var(--text);
    padding: 4px;
}
@keyframes popIn {
    from { opacity: 0; transform: scale(0.8); }
    to   { opacity: 1; transform: scale(1); }
}

/* ===== Alert / callout ===== */
.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    border: 1px solid transparent;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-info    { background: var(--info-soft);    color: var(--info);    border-color: color-mix(in srgb, var(--info) 25%, transparent); }

/* ===== Badge ===== */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px;
    font-size: 11.5px; font-weight: 500;
    border-radius: 999px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.badge-accent  { background: var(--accent-soft);  color: var(--accent);  border-color: transparent; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: transparent; }

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: var(--bg);
    padding: 12px 18px;
    border-radius: var(--radius);
    font-size: 13.5px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: all var(--t-slow) cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; align-items: center; gap: 10px;
    z-index: 100;
    max-width: calc(100vw - 32px);
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast svg { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }

/* ===== Scroll reveal utility ===== */
.reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.7s ease, transform 0.7s var(--ease);
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ===== Utility: eyebrow pill ===== */
.eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 5px 12px 5px 10px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.01em;
}
.eyebrow-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
    animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
    50%      { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent); }
}

/* ===== Utilities ===== */
.hidden { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

/* ===== Scrollbar (subtle) ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
    .reveal { opacity: 1; transform: none; }
}
