/* =========================================================
   KadOnline — Antara muka sistem (panel, laman utama, log masuk)
   Berasaskan DESIGN-apple-com.md:
   kanvas #f5f5f7 · teks #1d1d1f · aksen tunggal #71cfff
   SF Pro (peranti Apple) → Inter (lain-lain) · tajuk 600 & jarak huruf negatif
   bucu 28px+ / pil · bayang lembut · grid 7px
   ========================================================= */
:root {
    /* Token warna */
    --c-bg: #f5f5f7;
    --c-surface: #ffffff;
    --c-text: #1d1d1f;
    --c-text-2: #666666;
    --c-accent: #71cfff;           /* aksen tunggal — latar butang/sorotan (teks gelap di atasnya) */
    --c-accent-hover: #5ec6fb;
    --c-accent-soft: rgba(113, 207, 255, .22);
    --c-accent-ink: #0b6fa0;       /* hue sama, digelapkan untuk teks/pautan di atas putih (kontras AA) */
    --c-fill: #e8e8ed;
    --c-line: #d2d2d7;
    --c-graphite: #333336;

    /* Token bentuk & bayang */
    --r-sm: 14px;
    --r-card: 28px;
    --r-lg: 36px;
    --r-pill: 100px;
    --sh-mid: rgba(0, 0, 0, .08) 2px 4px 12px 0px;

    /* Grid 7px */
    --s1: 7px; --s2: 14px; --s3: 21px; --s4: 28px; --s6: 42px; --s9: 63px;

    --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Helvetica Neue", Arial, sans-serif;
    --font-text: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", Arial, sans-serif;
    --sidebar-w: 252px;

    /* Pemetaan Bootstrap */
    --bs-body-font-family: var(--font-text);
    --bs-body-bg: var(--c-bg);
    --bs-body-color: var(--c-text);
    --bs-emphasis-color: var(--c-text);
    --bs-secondary-color: var(--c-text-2);
    --bs-border-color: var(--c-line);
    --bs-primary: var(--c-accent);
    --bs-primary-rgb: 113, 207, 255;
    --bs-link-color: var(--c-accent-ink);
    --bs-link-color-rgb: 11, 111, 160;
    --bs-link-hover-color: #08577e;
    --bs-border-radius: var(--r-sm);
    --bs-border-radius-lg: var(--r-card);
    --bs-focus-ring-color: rgba(113, 207, 255, .45);
}

body { background: var(--c-bg); color: var(--c-text); font-size: 15px; letter-spacing: -.01em; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.02em; color: var(--c-text); }
.fw-bold, strong, b { font-weight: 600 !important; }
.text-muted { color: var(--c-text-2) !important; }
a { color: var(--c-accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
a.btn:hover, .sidebar-nav a:hover, .nav-link:hover, .brand-word:hover, .g-card:hover, .showcase a:hover { text-decoration: none; }

/* Grid jarak 7px */
.g-2 { --bs-gutter-x: var(--s2); --bs-gutter-y: var(--s2); }
.g-3 { --bs-gutter-x: var(--s3); --bs-gutter-y: var(--s3); }
.g-4 { --bs-gutter-x: var(--s4); --bs-gutter-y: var(--s4); }
.mb-3 { margin-bottom: var(--s3) !important; }
.mb-4 { margin-bottom: var(--s4) !important; }

/* ---------- Butang (pil) ---------- */
.btn { --bs-btn-border-radius: var(--r-pill); --bs-btn-font-weight: 600; --bs-btn-padding-x: 18px; --bs-btn-padding-y: 8px; --bs-btn-font-size: 15px; letter-spacing: -.01em; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-sm { --bs-btn-padding-x: 14px; --bs-btn-padding-y: 5px; --bs-btn-font-size: 13px; min-height: 32px; }
.btn-lg { --bs-btn-padding-x: 28px; --bs-btn-padding-y: 12px; --bs-btn-font-size: 17px; min-height: 48px; }
.btn-link { min-height: 0; }
.btn-primary {
    --bs-btn-bg: var(--c-accent); --bs-btn-border-color: var(--c-accent); --bs-btn-color: var(--c-text);
    --bs-btn-hover-bg: var(--c-accent-hover); --bs-btn-hover-border-color: var(--c-accent-hover); --bs-btn-hover-color: var(--c-text);
    --bs-btn-active-bg: #4bbdf5; --bs-btn-active-border-color: #4bbdf5; --bs-btn-active-color: var(--c-text);
    --bs-btn-disabled-bg: var(--c-accent); --bs-btn-disabled-border-color: var(--c-accent); --bs-btn-disabled-color: var(--c-text);
}
.btn-outline-primary, .btn-outline-secondary {
    --bs-btn-color: var(--c-text); --bs-btn-border-color: var(--c-line); --bs-btn-bg: var(--c-surface);
    --bs-btn-hover-bg: var(--c-fill); --bs-btn-hover-border-color: var(--c-line); --bs-btn-hover-color: var(--c-text);
    --bs-btn-active-bg: var(--c-line); --bs-btn-active-border-color: var(--c-line); --bs-btn-active-color: var(--c-text);
}
.btn-light {
    --bs-btn-bg: var(--c-fill); --bs-btn-border-color: var(--c-fill); --bs-btn-color: var(--c-text);
    --bs-btn-hover-bg: var(--c-line); --bs-btn-hover-border-color: var(--c-line);
    --bs-btn-active-bg: var(--c-line);
}
.btn-dark { --bs-btn-bg: var(--c-text); --bs-btn-border-color: var(--c-text); --bs-btn-hover-bg: var(--c-graphite); --bs-btn-hover-border-color: var(--c-graphite); }
.btn-check:checked + .btn, .btn:first-child:active { box-shadow: none; }
.btn:focus-visible { box-shadow: 0 0 0 4px var(--bs-focus-ring-color); }

/* ---------- Borang ---------- */
.form-control, .form-select { border-radius: var(--r-sm); border-color: var(--c-line); background-color: var(--c-surface); min-height: 44px; font-size: 15px; color: var(--c-text); }
.form-control-sm, .form-select-sm { min-height: 34px; font-size: 13px; border-radius: 10px; }
textarea.form-control { min-height: 88px; }
.form-control:focus, .form-select:focus { border-color: var(--c-accent); box-shadow: 0 0 0 4px var(--c-accent-soft); }
.form-control-color { min-height: 34px; padding: 4px; }
.input-group > .form-control-color { flex: 0 0 42px; width: 42px; max-width: 42px; }
.input-group-sm > .form-control { min-height: 34px; font-size: 13px; }
.form-label { font-weight: 600; font-size: 13px; color: var(--c-text); margin-bottom: var(--s1); }
.form-text { color: var(--c-text-2); }
.form-check-input { border-color: var(--c-line); }
.form-check-input:checked { background-color: var(--c-accent-ink); border-color: var(--c-accent-ink); }
.form-check-input:focus { box-shadow: 0 0 0 4px var(--c-accent-soft); border-color: var(--c-accent); }
.form-range::-webkit-slider-thumb { background: var(--c-accent-ink); }
.form-range::-moz-range-thumb { background: var(--c-accent-ink); }
.input-group-text { border-radius: var(--r-sm); background: var(--c-fill); border-color: var(--c-line); color: var(--c-text-2); }

/* ---------- Pil navigasi / tab ---------- */
.nav-pills { gap: var(--s1); }
.nav-pills .nav-link { border-radius: var(--r-pill); color: var(--c-text); font-weight: 500; padding: 7px 16px; background: transparent; }
.nav-pills .nav-link:hover { background: var(--c-fill); }
.nav-pills .nav-link.active { background: var(--c-text); color: #fff; }

/* ---------- Kad ---------- */
.card { border: 0; border-radius: var(--r-card); background: var(--c-surface); box-shadow: var(--sh-mid); }
.card-header { background: transparent; border-bottom: 0; font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: -.02em; padding: var(--s3) var(--s4) 0; border-radius: var(--r-card) var(--r-card) 0 0 !important; }
.card-body { padding: var(--s3) var(--s4); }
.card-footer { background: transparent !important; border-top: 1px solid var(--c-fill); padding: var(--s2) var(--s4); border-radius: 0 0 var(--r-card) var(--r-card) !important; }
.card > .list-group:last-child, .card > .table-responsive:last-child { border-radius: 0 0 var(--r-card) var(--r-card); overflow: hidden; }
.card.border-danger { box-shadow: 0 0 0 1px rgba(220, 53, 69, .35), var(--sh-mid); }
.list-group-item { border-color: var(--c-fill); padding: var(--s2) var(--s4); }

/* ---------- Jadual ---------- */
.table { --bs-table-bg: transparent; --bs-table-border-color: var(--c-fill); --bs-table-hover-bg: rgba(0, 0, 0, .025); margin-bottom: 0; }
.table > thead th { font-size: 12px; font-weight: 600; color: var(--c-text-2); border-bottom-color: var(--c-line); white-space: nowrap; }
.table > :not(caption) > * > * { vertical-align: middle; padding: 12px 14px; }
.table > :not(caption) > * > *:first-child { padding-left: var(--s4); }
.table > :not(caption) > * > *:last-child { padding-right: var(--s4); }

/* ---------- Lencana & amaran ---------- */
.badge { border-radius: var(--r-pill); font-weight: 600; padding: 5px 10px; letter-spacing: 0; }
.text-bg-primary { color: var(--c-text) !important; }   /* aksen cerah → teks gelap */
.text-bg-light { background: var(--c-fill) !important; color: var(--c-text) !important; }
.text-bg-secondary { background: var(--c-line) !important; color: var(--c-text) !important; }
.text-bg-dark { background: var(--c-text) !important; }
.alert { border: 0; border-radius: var(--r-sm); padding: var(--s2) var(--s3); }
.alert-success { background: #e3f5e8; color: #155724; }
.alert-danger { background: #fdeaea; color: #8a1c1c; }
.alert-warning { background: #fff5d6; color: #6b4d00; }
.alert-info { background: var(--c-accent-soft); color: #064a6b; }

/* ---------- Susun atur panel ---------- */
.panel-wrap { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); flex-shrink: 0; display: flex; flex-direction: column;
    background: rgba(255, 255, 255, .72); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-right: 1px solid var(--c-fill); color: var(--c-text);
}
@media (min-width: 992px) { .sidebar { position: sticky; top: 0; height: 100vh; } }
@media (max-width: 991.98px) { .sidebar.offcanvas-lg { background: var(--c-surface); } }
.sidebar-brand { padding: var(--s3) var(--s3) var(--s2); display: flex; align-items: center; justify-content: space-between; }
.sidebar-brand a, .brand-word { color: var(--c-text); text-decoration: none; font-family: var(--font-display); font-weight: 600; font-size: 21px; letter-spacing: -.03em; }
.brand-script { color: var(--c-accent-ink); font: inherit; margin: 0; }
.sidebar-nav { padding: var(--s1) var(--s2); flex: 1; overflow-y: auto; }
.sidebar-nav a { display: flex; align-items: center; gap: 12px; padding: 9px 14px; min-height: 40px; border-radius: var(--r-pill); color: var(--c-text); text-decoration: none; margin-bottom: 2px; font-weight: 500; font-size: 15px; }
.sidebar-nav a i { width: 18px; text-align: center; color: var(--c-text-2); }
.sidebar-nav a:hover { background: var(--c-fill); }
.sidebar-nav a.active { background: var(--c-accent-soft); color: var(--c-text); font-weight: 600; }
.sidebar-nav a.active i { color: var(--c-accent-ink); }
.nav-sep { font-size: 12px; font-weight: 600; color: var(--c-text-2); padding: var(--s3) 14px var(--s1); }
.sidebar-foot { padding: var(--s2) var(--s3) var(--s3); border-top: 1px solid var(--c-fill); }
.sidebar-foot .text-white-50 { color: var(--c-text-2) !important; }
.sidebar .btn-close-white { filter: none; }

.panel-main { flex: 1; min-width: 0; }
.topbar {
    position: sticky; top: 0; z-index: 100; display: flex; align-items: center; gap: var(--s2);
    padding: var(--s2) var(--s4); min-height: 63px;
    background: rgba(245, 245, 247, .8); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--c-fill);
}
.topbar h1 { font-size: 24px; letter-spacing: -.03em; }
.panel-body { padding: var(--s4); max-width: 1440px; }
@media (max-width: 639.98px) { .panel-body { padding: var(--s2); } .topbar { padding: var(--s1) var(--s2); } .topbar h1 { font-size: 19px; } .card-body { padding: var(--s2) var(--s3); } .card-header { padding: var(--s2) var(--s3) 0; } }

/* ---------- Statistik ---------- */
.stat-card { padding: var(--s3); display: flex; align-items: center; gap: var(--s2); }
.stat-icon { width: 49px; height: 49px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-size: 18px; background: var(--c-accent-soft); color: var(--c-accent-ink); flex-shrink: 0; }
.stat-num { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: -.03em; line-height: 1; }
.stat-lbl { font-size: 13px; color: var(--c-text-2); margin-top: 4px; }

/* ---------- Kad event (senarai Kad Saya) ---------- */
.event-card { overflow: hidden; }
.event-card .thumb { height: 140px; background: var(--c-text) center/cover; position: relative; }
.event-card .thumb .status { position: absolute; top: var(--s2); right: var(--s2); }
.event-card .thumb .names { position: absolute; inset: auto 0 var(--s2); text-align: center; font-family: 'Great Vibes', cursive; font-size: 30px; color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .45); padding: 0 var(--s2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-stats { display: flex; gap: var(--s2); font-size: 13px; color: var(--c-text-2); flex-wrap: wrap; }
.mini-stats span i { color: var(--c-accent-ink); }

/* ---------- Editor ---------- */
.editor-tabs { overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; scrollbar-width: none; padding: 4px; background: var(--c-fill); border-radius: var(--r-pill); display: inline-flex; max-width: 100%; }
.editor-tabs::-webkit-scrollbar { display: none; }
.editor-tabs .nav-link { padding: 7px 14px; font-size: 14px; }
.editor-tabs .nav-link.active { background: var(--c-surface); color: var(--c-text); box-shadow: rgba(0, 0, 0, .1) 0 1px 4px; }

.preview-pane { position: sticky; top: 84px; }
.phone-frame { width: 100%; max-width: 380px; margin: 0 auto; aspect-ratio: 9 / 18.5; border: 10px solid var(--c-text); border-radius: 50px; overflow: hidden; background: #000; box-shadow: rgba(0, 0, 0, .16) 0 21px 42px; }
.phone-frame iframe { width: 100%; height: 100%; border: 0; background: #fff; }

.comp-list .comp-item { display: flex; align-items: center; gap: var(--s2); padding: var(--s2); border: 0; border-radius: var(--r-sm); background: var(--c-bg); margin-bottom: var(--s1); }
.comp-item .handle { cursor: grab; color: #aeaeb2; padding: 4px; }
.comp-item .comp-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--c-surface); color: var(--c-accent-ink); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.comp-item.disabled { opacity: .5; }
.comp-item .place { font-size: 11px; }
.comp-item .badge.text-bg-primary { background: var(--c-accent-soft) !important; color: #064a6b !important; }
.comp-item .badge.text-bg-success { background: #e3f5e8 !important; color: #155724 !important; }
.sortable-ghost { opacity: .4; }

.img-slot { border: 1.5px dashed var(--c-line); border-radius: var(--r-sm); padding: var(--s1); text-align: center; background: var(--c-bg); }
.img-slot img { max-width: 100%; max-height: 120px; border-radius: 10px; object-fit: cover; }
.img-slot .empty { height: 84px; display: flex; align-items: center; justify-content: center; color: #aeaeb2; }

/* ---------- Pemilih tema ---------- */
.theme-pick { cursor: pointer; }
.theme-pick input { display: none; }
.theme-pick .tp { border-radius: var(--r-sm); overflow: hidden; background: var(--c-surface); box-shadow: 0 0 0 1px var(--c-fill); transition: box-shadow .2s, transform .2s; }
.theme-pick:hover .tp { transform: translateY(-2px); }
.theme-pick input:checked + .tp { box-shadow: 0 0 0 3px var(--c-accent), var(--sh-mid); }
.theme-pick .tp-img { height: 90px; background: #ccc center/cover; display: flex; align-items: flex-end; gap: 4px; padding: 6px; }
.theme-pick .tp-img i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; display: inline-block; }
.theme-pick .tp-name { padding: var(--s1) 10px; font-size: 12px; font-weight: 600; }
.theme-grid { max-height: 567px; overflow-y: auto; padding: 4px 4px 4px 0; }
.theme-pick .tp-thumb { aspect-ratio: 240 / 300; position: relative; overflow: hidden; }
.theme-pick .tp-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.theme-pick .tp-dots { position: absolute; left: 6px; bottom: 6px; display: flex; gap: 3px; }
.theme-pick .tp-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; display: inline-block; }
.theme-pick .tp-badge { position: absolute; top: 6px; right: 6px; font-size: 10px; }

/* ---------- Log masuk / daftar ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--s2); background: var(--c-bg); }
.auth-card { width: 100%; max-width: 434px; background: var(--c-surface); border-radius: var(--r-lg); padding: var(--s6) var(--s4); box-shadow: var(--sh-mid); }
.auth-card .brand { text-align: center; margin-bottom: var(--s1); }
.auth-card .brand .brand-word { font-size: 28px; }

/* ---------- Galeri (tab Galeri editor) ---------- */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(133px, 1fr)); gap: var(--s2); }
.gallery-grid .gi { position: relative; border-radius: var(--r-sm); overflow: hidden; background: var(--c-bg); }
.gallery-grid img { width: 100%; height: 112px; object-fit: cover; display: block; }
.font-preview { font-size: 22px; }

/* ---------- Laman awam ---------- */
.site-nav { position: sticky; top: 0; z-index: 50; background: rgba(245, 245, 247, .8); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--c-fill); }
.site-nav .container { min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.display-hero { font-family: var(--font-display); font-weight: 600; font-size: 80px; line-height: 1.05; letter-spacing: -.015em; }
.lead-hero { font-size: 21px; color: var(--c-text-2); line-height: 1.45; letter-spacing: -.01em; }
.link-chevron { font-weight: 600; text-decoration: none; font-size: 17px; }
.link-chevron:hover { text-decoration: underline; }
@media (max-width: 639.98px) { .display-hero { font-size: 44px; } .lead-hero { font-size: 17px; } }

/* ---------- Borang reka bentuk (Tema & Edit Kad → Reka Bentuk) ---------- */
.tf-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tf-chips label { margin: 0; }
.tf-chips input { display: none; }
.tf-chips span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r-pill); background: var(--c-bg); box-shadow: 0 0 0 1px var(--c-fill); font-size: 13px; cursor: pointer; transition: .15s; }
.tf-chips input:checked + span { background: var(--c-accent); color: #fff; box-shadow: none; }
.tf-swatch { border-radius: 18px; padding: 18px; text-align: center; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); transition: background .2s; }
.tf-swatch .s1 { font-size: 34px; line-height: 1.1; }
.tf-swatch .s2 { font-size: 13px; letter-spacing: 3px; text-transform: uppercase; margin-top: 4px; }
.tf-swatch .s3 { font-size: 13px; margin-top: 6px; opacity: .85; }
.tf-swatch .s4 { display: inline-block; margin-top: 10px; padding: 6px 18px; border-radius: 30px; color: #fff; font-size: 11px; letter-spacing: 2px; text-transform: uppercase; }
.tf-font { border-radius: 14px; background: var(--c-bg); padding: 10px 12px; margin-top: 6px; min-height: 58px; display: flex; align-items: center; overflow: hidden; }
.tf-dots { display: flex; gap: 6px; }
.tf-dots i { width: 22px; height: 22px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--c-fill); }
.tf-save { position: sticky; bottom: 0; z-index: 30; background: color-mix(in srgb, var(--c-bg) 88%, transparent); backdrop-filter: blur(12px); padding: 12px 0; margin-top: 4px; }
.tf-src { font-size: 10px; position: absolute; top: 6px; right: 6px; }
.img-slot { position: relative; }
.card[id] { scroll-margin-top: 80px; }

/* Senarai tema admin: 5 butang tindakan dalam grid sama lebar (tidak melimpah keluar kad) */
.th-actions { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.th-actions .btn, .th-actions form .btn { width: 100%; min-width: 0; padding: 5px 0; display: flex; align-items: center; justify-content: center; }
.th-actions form { margin: 0; min-width: 0; }
