/* =====================================================================
   BUKU TAMU DIGITAL PRO
   File: assets/css/style.css
   Tema: Premium Dark Modern
   ===================================================================== */

:root {
    --bg: #0f172a;
    --card: #111827;
    --card-secondary: #1e293b;
    --text-primary: #ffffff;
    --text-secondary: #cbd5e1;
    --border: rgba(255, 255, 255, .10);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, .35);
    --transition: all .2s ease;
}

* { box-sizing: border-box; }

html, body {
    min-height: 100%;
    overflow-x: hidden;
}

body {
    background: radial-gradient(circle at top left, #16213e 0%, var(--bg) 45%) fixed;
    color: var(--text-primary);
    font-family: 'Poppins', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

::selection { background: var(--primary); color: #fff; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--card-secondary); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ---------- Typography helpers ---------- */
.text-secondary-custom { color: var(--text-secondary) !important; }
.text-primary-custom { color: var(--primary) !important; }
.fw-semibold { font-weight: 600; }

/* ---------- Glass Card ---------- */
.glass-card {
    background: linear-gradient(145deg, var(--card) 0%, var(--card-secondary) 120%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
    transition: var(--transition);
}

.glass-card:hover { border-color: rgba(59, 130, 246, .35); }

.card-flat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: var(--transition);
    padding: .55rem 1.1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    border: none;
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), #4f46e5);
    transform: translateY(-1px);
}

.btn-success { background: var(--success); border: none; }
.btn-warning { background: var(--warning); border: none; color: #1a1a1a; }
.btn-danger  { background: var(--danger); border: none; }
.btn-info    { background: var(--info); border: none; }

.btn-outline-light {
    border-color: var(--border);
    color: var(--text-primary);
}
.btn-outline-light:hover {
    background: rgba(255, 255, 255, .08);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-lg-touch {
    min-height: 56px;
    font-size: 1.05rem;
}

/* ---------- Forms ---------- */
.form-control, .form-select {
    background: rgba(255, 255, 255, .03);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: .65rem .9rem;
    min-height: 46px;
}
.form-control:focus, .form-select:focus {
    background: rgba(255, 255, 255, .05);
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(59, 130, 246, .18);
    color: var(--text-primary);
}
.form-control::placeholder { color: #64748b; }
.form-label { color: var(--text-secondary); font-weight: 500; margin-bottom: .4rem; }
.form-text { color: #64748b; }

.input-group-text {
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

/* ---------- Navbar (Admin) ---------- */
.app-navbar {
    background: rgba(17, 24, 39, .85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

/* ---------- Sidebar (Admin) ---------- */
.app-sidebar {
    background: var(--card);
    border-right: 1px solid var(--border);
    width: 260px;
    min-height: 100vh;
    transition: var(--transition);
}

.app-sidebar .nav-link {
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: .65rem .9rem;
    margin-bottom: .2rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    font-size: .92rem;
}
.app-sidebar .nav-link:hover {
    background: rgba(59, 130, 246, .10);
    color: var(--text-primary);
}
.app-sidebar .nav-link.active {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff;
}
.app-sidebar .nav-section-title {
    color: #64748b;
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .08em;
    padding: 1rem .9rem .3rem;
}

.app-content { min-height: 100vh; }

/* ---------- Sidebar mobile off-canvas ---------- */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        z-index: 1045;
        box-shadow: var(--shadow-soft);
    }
    .app-sidebar.show { left: 0; }
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .55);
        z-index: 1040;
    }
    .sidebar-backdrop.show { display: block; }
}

/* ---------- Stat Cards ---------- */
.stat-card {
    padding: 1.25rem;
    border-radius: var(--radius);
}
.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}
.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
}
.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: .82rem;
}

/* ---------- Tables ---------- */
.table {
    color: var(--text-primary);
    --bs-table-bg: transparent;
}
.table > :not(caption) > * > * {
    border-color: var(--border);
    background: transparent;
}
.table thead th {
    color: var(--text-secondary);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom-width: 1px;
    white-space: nowrap;
}
.table-hover > tbody > tr:hover > * {
    background: rgba(59, 130, 246, .06);
}
.table-responsive { border-radius: var(--radius); }

/* DataTables dark overrides */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: var(--text-secondary);
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--text-secondary) !important;
    border-radius: var(--radius-sm) !important;
    border: 1px solid transparent !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    color: #fff !important;
    border: none !important;
}

/* ---------- Badges ---------- */
.badge-status {
    padding: .4em .75em;
    border-radius: 999px;
    font-weight: 500;
    font-size: .75rem;
}
.badge-menunggu  { background: rgba(245, 158, 11, .15); color: var(--warning); }
.badge-berkunjung{ background: rgba(6, 182, 212, .15); color: var(--info); }
.badge-selesai   { background: rgba(34, 197, 94, .15); color: var(--success); }
.badge-sent      { background: rgba(34, 197, 94, .15); color: var(--success); }
.badge-failed    { background: rgba(239, 68, 68, .15); color: var(--danger); }
.badge-pending   { background: rgba(245, 158, 11, .15); color: var(--warning); }

/* ---------- Public Guestbook Page ---------- */
.public-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.public-logo { max-height: 90px; margin-bottom: 1rem; }
.public-card {
    max-width: 520px;
    width: 100%;
    padding: 2.5rem 2rem;
    text-align: center;
}
.public-title {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, #93c5fd);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.public-subtitle { color: var(--text-secondary); margin-bottom: 1.75rem; }

.form-wrapper {
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

/* ---------- Camera & Signature ---------- */
.camera-box, .signature-box {
    background: rgba(255, 255, 255, .03);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
}
.camera-box video,
.camera-box img#photoPreview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.signature-box {
    aspect-ratio: 16 / 7;
    touch-action: none;
}
.signature-box canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}
.camera-placeholder, .signature-placeholder {
    color: #64748b;
    text-align: center;
    padding: 1rem;
}

/* ---------- Login Page ---------- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.login-card {
    max-width: 400px;
    width: 100%;
    padding: 2.25rem 2rem;
}

/* ---------- Loading Overlay ---------- */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .85);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    z-index: 2000;
}
.loading-overlay.show { display: flex; }
.spinner-ring {
    width: 48px; height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}
.empty-state i { font-size: 2.5rem; color: #475569; margin-bottom: .75rem; display: block; }

/* ---------- Print (bukti kunjungan) ---------- */
@media print {
    body { background: #fff !important; color: #000 !important; }
    .no-print { display: none !important; }
    .print-area { color: #000 !important; }
}

/* ---------- Print-only utility (kebalikan dari .no-print) ---------- */
.print-only { display: none; }
@media print {
    .print-only { display: block !important; }
    .app-content { padding: 0 !important; }
    .glass-card { background: #fff !important; border: 1px solid #ccc !important; box-shadow: none !important; }
    .table thead th, .table td { color: #000 !important; border-color: #ddd !important; }
    canvas { max-width: 100% !important; }
}

/* ---------- Laporan: header cetak (PHASE 15) ---------- */
.laporan-print-header {
    text-align: center;
    color: #000;
    margin-bottom: 1rem;
}
.laporan-print-header img { max-height: 60px; margin-bottom: .5rem; }
.laporan-print-header hr { border-color: #999; margin: .75rem 0; }

/* ---------- Laporan: tombol periode aktif (PHASE 15) ---------- */
.period-btn.active { pointer-events: none; }

/* =====================================================================
   RESPONSIVE AUDIT
   Breakpoints target: 360 375 390 414 768 1024 1366 1920
   ===================================================================== */
@media (max-width: 575.98px) {
    .public-card, .login-card { padding: 1.75rem 1.25rem; }
    .public-title { font-size: 1.45rem; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .app-content { padding: 1rem !important; }
    .table-responsive { font-size: .85rem; }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    .app-content { padding: 1.25rem !important; }
}

@media (min-width: 1400px) {
    .app-content { padding: 2rem 2.5rem !important; }
}

.overflow-guard { max-width: 100%; overflow-x: auto; }

/* ---------- Data Tamu: thumbnail & detail preview (PHASE 10) ---------- */
.table-thumb {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border);
    cursor: zoom-in;
}
.table-thumb-empty {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 1rem;
}
.detail-img-wrap {
    background: rgba(255, 255, 255, .03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .6rem;
    text-align: center;
}
.detail-img-wrap img {
    max-width: 100%;
    max-height: 220px;
    border-radius: var(--radius-sm);
    cursor: zoom-in;
}
.detail-label {
    color: var(--text-secondary);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: .15rem;
}
.detail-value { font-weight: 500; word-break: break-word; }

.filter-bar .form-control,
.filter-bar .form-select { min-height: 42px; padding: .5rem .8rem; font-size: .9rem; }

.action-dropdown .dropdown-menu {
    background: var(--card);
    border: 1px solid var(--border);
    min-width: 190px;
}
.action-dropdown .dropdown-item {
    color: var(--text-secondary);
    font-size: .88rem;
    padding: .5rem .8rem;
    border-radius: 8px;
}
.action-dropdown .dropdown-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.action-dropdown .dropdown-item.text-danger:hover { background: rgba(239, 68, 68, .12); }
.action-dropdown .dropdown-item i { width: 18px; display: inline-block; }

/* ---------- Dark Tabs (mis. Pengaturan / Template WhatsApp) ---------- */
.wa-tabs.nav-tabs {
    border-bottom: 1px solid var(--border);
    gap: .25rem;
}
.wa-tabs.nav-tabs .nav-link {
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-weight: 500;
    font-size: .9rem;
    padding: .6rem 1.1rem;
}
.wa-tabs.nav-tabs .nav-link:hover {
    color: #fff;
    border-color: var(--border);
}
.wa-tabs.nav-tabs .nav-link.active {
    color: #fff;
    background: var(--card-secondary);
    border-color: var(--border);
    border-bottom-color: var(--card-secondary);
}

/* ---------- Template WhatsApp: placeholder chips ---------- */
.wa-placeholder-chip {
    display: inline-flex;
    align-items: center;
    background: rgba(59, 130, 246, .12);
    border: 1px solid rgba(59, 130, 246, .3);
    color: #93c5fd;
    font-family: 'Courier New', monospace;
    font-size: .76rem;
    padding: .28rem .6rem;
    border-radius: 999px;
    cursor: pointer;
    transition: var(--transition);
}
.wa-placeholder-chip:hover {
    background: rgba(59, 130, 246, .22);
    color: #fff;
    transform: translateY(-1px);
}

/* ---------- Template WhatsApp: textarea ---------- */
.wa-template-textarea {
    font-family: 'Courier New', monospace;
    font-size: .85rem;
    line-height: 1.6;
    resize: vertical;
}

/* ---------- Template WhatsApp: preview bubble (mirip tampilan chat) ---------- */
.wa-chat-preview-wrap {
    background: #0b141a;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    background-image: radial-gradient(rgba(255,255,255,.03) 1px, transparent 1px);
    background-size: 14px 14px;
}
.wa-chat-bubble {
    background: #005c4b;
    color: #e9edef;
    border-radius: 10px;
    border-top-left-radius: 2px;
    padding: .65rem .8rem;
    max-width: 88%;
    font-size: .85rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.wa-chat-time {
    color: rgba(233,237,239,.55);
    font-size: .68rem;
    text-align: right;
    margin-top: .25rem;
}

/* =====================================================================
   QR CODE BUKU TAMU (PHASE 17)
   ===================================================================== */

/* Kotak putih pembungkus QR di layar — kontras tetap terjaga walau tema gelap,
   dan menjaga "quiet zone" QR agar tetap mudah discan kamera. */
.qr-white-box {
    background: #ffffff;
    padding: 1.25rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.qr-white-box #qrcodeDisplay img,
.qr-white-box #qrcodeDisplay canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.qr-size-btn.active { pointer-events: none; }

/* Poster cetak: hanya tampil saat print (memakai .print-only, lihat di atas) */
.qr-print-poster {
    text-align: center;
    color: #000;
    padding: 2rem 1rem;
}
.qr-print-logo { max-height: 70px; margin-bottom: .75rem; }
.qr-print-address { color: #333; margin-bottom: 1rem; }
.qr-print-box {
    display: inline-flex;
    background: #fff;
    padding: 1.5rem;
    border: 2px solid #000;
    margin: 0 auto;
}
.qr-print-sub { color: #333; margin-top: .5rem; }

@media print {
    .qr-print-poster { padding: 0; }
}

/* =====================================================================
   BACKUP DATABASE (PHASE 19)
   ===================================================================== */
.alert-info-custom {
    background: rgba(6, 182, 212, .10);
    border: 1px solid rgba(6, 182, 212, .30);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: .85rem 1rem;
    font-size: .85rem;
}
.alert-info-custom code {
    background: rgba(255,255,255,.08);
    padding: .1rem .4rem;
    border-radius: 4px;
    color: var(--info);
}

.backup-item {
    background: var(--card-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
}

/* =====================================================================
   POLISH PASS — nuansa premium untuk halaman publik, login & dashboard
   ===================================================================== */

/* ---------- Ambient glow di belakang halaman publik & login ---------- */
body.public-body {
    position: relative;
    overflow-x: hidden;
}
body.public-body::before,
body.public-body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    pointer-events: none;
}
body.public-body::before {
    width: 420px; height: 420px;
    top: -140px; left: -120px;
    background: radial-gradient(circle, rgba(59,130,246,.30), transparent 70%);
}
body.public-body::after {
    width: 480px; height: 480px;
    bottom: -160px; right: -140px;
    background: radial-gradient(circle, rgba(99,102,241,.24), transparent 70%);
}
body.public-body > * { position: relative; z-index: 1; }

/* ---------- Public hero: micro-interactions ---------- */
.public-card { position: relative; overflow: hidden; }
.public-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #818cf8, var(--info));
}
.public-logo { filter: drop-shadow(0 4px 14px rgba(59,130,246,.35)); }

#btnStartForm { position: relative; overflow: hidden; }
#btnStartForm:hover { box-shadow: 0 8px 24px rgba(59,130,246,.35); }

.login-card { position: relative; overflow: hidden; }
.login-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #818cf8, var(--info));
}

/* ---------- Dashboard greeting banner ---------- */
.dash-greeting-banner {
    position: relative;
    overflow: hidden;
    padding: 1.5rem 1.75rem;
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(59,130,246,.16), rgba(99,102,241,.10) 55%, rgba(6,182,212,.08));
    border: 1px solid var(--border);
    margin-bottom: 1.25rem;
}
.dash-greeting-banner::after {
    content: '';
    position: absolute;
    top: -60px; right: -60px;
    width: 220px; height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(59,130,246,.25), transparent 70%);
    pointer-events: none;
}
.dash-greeting-banner .dash-greeting-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: .15rem;
}
.dash-greeting-banner .dash-greeting-sub {
    color: var(--text-secondary);
    font-size: .88rem;
}
.dash-greeting-banner .dash-greeting-clock {
    font-size: 1.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
}
.dash-greeting-banner .dash-greeting-date {
    color: var(--text-secondary);
    font-size: .8rem;
}

/* ---------- Stat cards: lift + accent ---------- */
.stat-card {
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}
.stat-card:hover {
    transform: translateY(-3px);
    border-color: rgba(59, 130, 246, .35);
    box-shadow: 0 14px 32px rgba(0,0,0,.4);
}
.stat-card .stat-icon { transition: var(--transition); }
.stat-card:hover .stat-icon { transform: scale(1.08); }

/* ---------- Sidebar brand mark subtle glow ---------- */
.app-sidebar .fw-semibold.text-primary-custom,
.app-sidebar .bi-journal-bookmark-fill { filter: drop-shadow(0 0 10px rgba(59,130,246,.45)); }

/* ---------- Profile page avatar ring ---------- */
.glass-card .rounded-circle[style*="linear-gradient"] {
    box-shadow: 0 0 0 4px rgba(59,130,246,.15), 0 10px 24px rgba(59,130,246,.25);
}

@media (max-width: 575.98px) {
    .dash-greeting-banner { padding: 1.15rem 1.25rem; }
    .dash-greeting-banner .dash-greeting-clock { font-size: 1.3rem; }
}
