* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Pastel Blue */
    --sky-50: #f0f8ff; --sky-100: #dff0ff; --sky-200: #bce2ff; --sky-300: #89ceff;
    --sky-400: #53b8ff; --sky-500: #2b9cff; --sky-600: #0078e7; --sky-700: #005bbf;
    /* Pastel Green */
    --leaf-50: #f0fff4; --leaf-100: #dcffed; --leaf-200: #b8ffd8; --leaf-300: #77ffaa;
    --leaf-400: #3deb77; --leaf-500: #00d25a; --leaf-600: #00a645; --leaf-700: #007a33;
    /* Pastel Yellow */
    --orange-50: #fffdf0; --orange-100: #fffacc; --orange-200: #fff599; --orange-300: #ffee66;
    --orange-400: #ffe533; --orange-500: #ffd700; --orange-600: #ccac00; --orange-700: #998000;
    /* Pastel Pink */
    --sunset-50: #fff0f5; --sunset-100: #ffe0ea; --sunset-200: #ffc2d6; --sunset-300: #ff9dbb;
    --sunset-400: #ff6b95; --sunset-500: #ff3d71; --sunset-600: #e6004c; --sunset-700: #b3003c;

    --gradient-main: linear-gradient(135deg, #53b8ff, #00d25a);
    --gradient-warm: linear-gradient(135deg, #ffd700, #ff6b95);
    
    --bg-main: #fafbff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden; /* Mencegah scroll kanan kiri secara global */
}

/* ========== ANIMATED BACKGROUND BLOBS ========== */
body::before, body::after {
    content: ''; position: fixed; border-radius: 50%; filter: blur(80px); opacity: 0.15; z-index: 0; pointer-events: none; animation: floatBlob 20s ease-in-out infinite;
}
body::before { width: 500px; height: 500px; background: var(--sky-400); top: -150px; left: -100px; }
body::after { width: 400px; height: 400px; background: var(--leaf-400); bottom: -100px; right: -80px; animation-delay: -10s; animation-direction: reverse; }

@keyframes floatBlob {
    0%, 100% { transform: translate(0, 0) scale(1); } 25% { transform: translate(40px, 30px) scale(1.1); } 50% { transform: translate(-20px, 60px) scale(0.95); } 75% { transform: translate(30px, -20px) scale(1.05); }
}

/* ========== HEADER ========== */
.top-header {
    background: linear-gradient(135deg, #003d7a, #004d2e, #1e293b);
    background-size: 200% 200%; animation: gradientShift 8s ease infinite;
    color: #fff; padding: 0 20px; height: 60px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 100; box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
@keyframes gradientShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

.top-header h1 { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.top-header h1 svg { width: 22px; height: 22px; stroke: var(--sky-300); flex-shrink: 0; }

.header-nav { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.header-nav a {
    color: #cbd5e1; font-size: 0.78rem; text-decoration: none; padding: 6px 12px; border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1); transition: all 0.3s; white-space: nowrap;
}
.header-nav a:hover { color: #fff; background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.2); }
.header-nav a.active { color: var(--sky-300); border-color: rgba(137,206,255,0.4); background: rgba(137,206,255,0.1); }
.header-nav .btn-logout { color: var(--sunset-300); border-color: rgba(255,107,149,0.2); }

/* ========== CONTAINER ========== */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 16px; position: relative; z-index: 1; }

/* ========== CARDS ========== */
.card {
    background: rgba(255,255,255,0.85); backdrop-filter: blur(12px); border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.6); margin-bottom: 24px; overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.04); animation: fadeInUp 0.5s ease-out;
}
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.card-header { padding: 18px 20px; border-bottom: 1px solid var(--border-color); font-weight: 700; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.card-header svg { width: 20px; height: 20px; color: var(--sky-500); flex-shrink: 0; }
.card-body { padding: 20px; }

/* ========== STATS GRID ========== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }

.stat-card {
    background: rgba(255,255,255,0.9); backdrop-filter: blur(10px); border-radius: 14px; padding: 16px;
    border: 1px solid rgba(255,255,255,0.6); display: flex; align-items: center; gap: 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.03); transition: all 0.3s;
}
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.green { background: linear-gradient(135deg, var(--leaf-100), var(--leaf-200)); color: var(--leaf-600); }
.stat-icon.blue { background: linear-gradient(135deg, var(--sky-100), var(--sky-200)); color: var(--sky-600); }
.stat-icon.yellow { background: linear-gradient(135deg, var(--orange-100), var(--orange-200)); color: var(--orange-600); }
.stat-icon.red { background: linear-gradient(135deg, var(--sunset-100), var(--sunset-200)); color: var(--sunset-600); }
.stat-value { font-size: 1.4rem; font-weight: 800; color: var(--text-primary); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ========== FORMS ========== */
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.grow { flex: 1; min-width: 150px; }
.form-group label { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; }

.form-control {
    padding: 10px 14px; border: 2px solid var(--border-color); border-radius: 10px; font-size: 0.88rem;
    font-family: 'Inter', sans-serif; outline: none; transition: all 0.3s; background: rgba(255,255,255,0.8); width: 100%;
}
.form-control:focus { border-color: var(--sky-400); box-shadow: 0 0 0 4px rgba(83,184,255,0.15); background: #fff; }

textarea.form-control { min-height: 80px; resize: vertical; font-family: monospace; }

/* ========== BUTTONS ========== */
.btn {
    padding: 10px 20px; border: none; border-radius: 10px; font-size: 0.85rem; font-weight: 600;
    font-family: 'Inter', sans-serif; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
    transition: all 0.3s; white-space: nowrap; text-decoration: none; position: relative; overflow: hidden;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn::after { content: ''; position: absolute; inset: 0; background: rgba(255,255,255,0); transition: background 0.3s; }
.btn:hover::after { background: rgba(255,255,255,0.15); }

.btn-primary { background: var(--gradient-main); color: #fff; box-shadow: 0 4px 12px rgba(43,156,255,0.3); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(43,156,255,0.45); transform: translateY(-2px); }

.btn-danger { background: linear-gradient(135deg, var(--sunset-100), var(--sunset-200)); color: var(--sunset-600); }
.btn-danger:hover { background: linear-gradient(135deg, var(--sunset-200), var(--sunset-300)); }

.btn-secondary { background: var(--bg-main); color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: #e2e8f0; }

.btn-danger-solid { background: var(--gradient-warm); color: #fff; box-shadow: 0 4px 12px rgba(255,61,113,0.3); }
.btn-danger-solid:hover { box-shadow: 0 6px 20px rgba(255,61,113,0.45); transform: translateY(-2px); }

.btn-sm { padding: 6px 12px; font-size: 0.78rem; border-radius: 8px; }

/* ========== MESSAGES ========== */
.msg-box { padding: 14px 18px; border-radius: 12px; margin-bottom: 20px; font-size: 0.88rem; display: flex; align-items: flex-start; gap: 10px; animation: slideIn 0.4s ease-out; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }
.msg-box svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.msg-success { background: linear-gradient(135deg, var(--leaf-50), var(--leaf-100)); color: var(--leaf-700); border: 1px solid var(--leaf-200); }
.msg-error { background: linear-gradient(135deg, var(--sunset-50), var(--sunset-100)); color: var(--sunset-700); border: 1px solid var(--sunset-200); }

/* ========== TABLE ========== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }

.data-table { width: 100%; border-collapse: collapse; min-width: 700px; /* Mencegah tabel penyok, jadi scroll horizontal */ }
.data-table thead th {
    text-align: left; padding: 12px 16px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); font-weight: 600; background: linear-gradient(135deg, var(--sky-50), var(--leaf-50));
    border-bottom: 2px solid var(--sky-300); white-space: nowrap;
}
.data-table tbody td { padding: 12px 16px; border-bottom: 1px solid rgba(226, 232, 240, 0.6); font-size: 0.85rem; vertical-align: middle; }
.data-table tbody tr:hover td { background: linear-gradient(135deg, rgba(83,184,255,0.05), rgba(0,210,90,0.05)); }

.col-no { text-align: center; font-weight: 700; color: var(--text-muted); font-size: 0.82rem; width: 50px; }

.key-text { font-family: 'Courier New', monospace; font-weight: 700; letter-spacing: 1px; background: linear-gradient(135deg, var(--sky-50), var(--leaf-50)); padding: 4px 8px; border-radius: 6px; font-size: 0.8rem; display: inline-block; border: 1px solid var(--sky-200); }
.copy-btn { background: none; border: 1px solid var(--border-color); border-radius: 6px; padding: 3px 8px; cursor: pointer; font-size: 0.7rem; color: var(--text-muted); transition: all 0.2s; }
.copy-btn:hover { background: var(--sky-50); color: var(--sky-600); }
.copy-btn.copied { background: var(--leaf-50); color: var(--leaf-600); }

/* ========== STATUS BADGE ========== */
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.status-badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge-unused { background: var(--sky-50); color: var(--sky-700); border: 1px solid var(--sky-200); } .badge-unused .dot { background: var(--sky-500); }
.badge-active { background: var(--leaf-50); color: var(--leaf-700); border: 1px solid var(--leaf-200); } .badge-active .dot { background: var(--leaf-500); animation: pulse-dot 2s infinite; }
.badge-expired { background: var(--sunset-50); color: var(--sunset-700); border: 1px solid var(--sunset-200); } .badge-expired .dot { background: var(--sunset-500); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ========== TABLE TOP BAR & PAGINATION ========== */
.table-top-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border-color); background: rgba(255,255,255,0.5); flex-wrap: wrap; }
.perpage-selector { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--text-secondary); white-space: nowrap; }
.perpage-selector select { padding: 6px 10px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 0.82rem; outline: none; background: #fff; }
.table-search { position: relative; width: 250px; max-width: 100%; }
.table-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--text-muted); }
.table-search input { width: 100%; padding: 8px 12px 8px 36px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 0.82rem; outline: none; background: #fff; }
.table-search .search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1rem; }

.pagination-wrapper { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-top: 1px solid var(--border-color); background: rgba(255,255,255,0.5); flex-wrap: wrap; gap: 12px; }
.pagination-info { font-size: 0.8rem; color: var(--text-muted); }
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pagination a, .pagination span { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; font-size: 0.8rem; font-weight: 600; text-decoration: none; border: 1px solid transparent; }
.pagination a { color: var(--text-secondary); background: rgba(255,255,255,0.6); border-color: var(--border-color); }
.pagination a:hover { background: var(--sky-50); border-color: var(--sky-200); color: var(--sky-600); }
.pagination a.active { background: var(--gradient-main); color: #fff; border-color: transparent; }
.pagination a.disabled { opacity: 0.35; pointer-events: none; }
.pagination .dots { color: var(--text-muted); min-width: 20px; background: none; border: none; }

/* ========== PASSWORD WRAPPER ========== */
.password-wrapper { position: relative; width: 100%; }
.password-wrapper input { width: 100%; padding-right: 44px; }
.password-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-muted); height: 24px; width: 24px; z-index: 2; padding: 0;}
.password-toggle svg { width: 20px; height: 20px; }

.form-control-pw { width: 100%; padding: 10px 44px 10px 14px; border: 2px solid var(--border-color); border-radius: 10px; font-size: 0.9rem; outline: none; background: rgba(255,255,255,0.8); }
.inline-pw-wrapper { position: relative; display: inline-flex; align-items: center; }
.inline-pw-wrapper input { padding: 5px 32px 5px 8px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 0.78rem; width: 120px; outline: none; }
.inline-pw-wrapper .password-toggle { right: 6px; width: 16px; height: 16px; } .inline-pw-wrapper .password-toggle svg { width: 16px; height: 16px; }

/* ========== LOGIN PAGE ========== */
.login-wrapper { 
    position: fixed; /* Kunci posisi agar menutupi layar sempurna tanpa celah */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    background: linear-gradient(135deg, var(--sky-100), var(--sunset-100), var(--orange-100), var(--leaf-100)); 
    background-size: 400% 400%; 
    animation: gradientShift 12s ease infinite; 
    padding: 20px;
    overflow-y: auto; /* Penting: Agar form bisa di-scroll saat keyboard HP muncul */
    overflow-x: hidden;
}

.login-card { background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.8); border-radius: 24px; padding: 40px 30px; width: 100%; max-width: 420px; position: relative; z-index: 1; box-shadow: 0 20px 60px rgba(0,0,0,0.08); animation: cardAppear 0.6s ease-out; }
@keyframes cardAppear { from { opacity: 0; transform: scale(0.9) translateY(30px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.login-card h2 { color: var(--text-primary); text-align: center; margin-bottom: 8px; font-size: 1.5rem; }
.login-card p { color: var(--text-secondary); text-align: center; font-size: 0.85rem; margin-bottom: 24px; }
.login-card label { color: var(--text-secondary); font-size: 0.78rem; font-weight: 600; display: block; margin-bottom: 6px; }
.login-card input { width: 100%; padding: 12px 14px; background: rgba(255, 255, 255, 0.9); border: 2px solid var(--sky-200); border-radius: 12px; font-size: 0.9rem; outline: none; margin-bottom: 16px; transition: all 0.3s; }
.login-card input:focus { border-color: var(--sky-400); box-shadow: 0 0 0 4px rgba(83,184,255,0.15); background: #fff; }
.login-card .btn { width: 100%; justify-content: center; padding: 14px; font-size: 1rem; background: linear-gradient(135deg, var(--sky-400), var(--leaf-400)); color: #fff; border-radius: 12px; box-shadow: 0 4px 15px rgba(83,184,255,0.3); }

/* ========== TOAST & MODAL ========== */
.toast-container { position: fixed; top: 80px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-radius: 14px; font-size: 0.88rem; font-weight: 500; box-shadow: 0 10px 30px rgba(0,0,0,0.15); animation: toastIn 0.4s ease-out forwards; pointer-events: auto; max-width: 350px; backdrop-filter: blur(10px); }
.toast svg { width: 20px; height: 20px; flex-shrink: 0; }
.toast-success { background: rgba(240, 255, 244, 0.95); border: 1px solid var(--leaf-200); color: var(--leaf-700); }
.toast-error { background: rgba(255, 240, 245, 0.95); border: 1px solid var(--sunset-200); color: var(--sunset-700); }
@keyframes toastIn { from { opacity: 0; transform: translateX(60px) scale(0.9); } to { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(60px); } }

.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(6px); z-index: 10000; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: all 0.3s; padding: 20px; }
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal-card { background: #fff; border-radius: 20px; padding: 32px; width: 100%; max-width: 420px; box-shadow: 0 25px 60px rgba(0,0,0,0.2); transform: scale(0.9) translateY(20px); transition: transform 0.3s; text-align: center; }
.modal-overlay.show .modal-card { transform: scale(1) translateY(0); }
.modal-icon { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; background: linear-gradient(135deg, var(--sunset-100), var(--sunset-200)); }
.modal-icon svg { width: 32px; height: 32px; stroke: var(--sunset-500); }
.modal-card h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 8px; }
.modal-card p { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 28px; line-height: 1.5; }
.modal-actions { display: flex; gap: 12px; justify-content: center; }
.modal-actions .btn { min-width: 120px; justify-content: center; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.4; }

.login-card .password-wrapper {
    margin-bottom: 16px;
    position: relative;
}
.login-card .password-wrapper input {
    margin-bottom: 0;
    padding-right: 44px;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--sky-50); }
::-webkit-scrollbar-thumb { background: linear-gradient(135deg, var(--sky-300), var(--leaf-400)); border-radius: 4px; }
::selection { background: rgba(83,184,255,0.25); }

/* ==========================================================
   MOBILE RESPONSIVE (HANDPHONE)
   ========================================================== */
@media (max-width: 768px) {
    /* Header Rapih */
    .top-header {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 16px;
        gap: 8px;
    }
    .top-header h1 {
        width: 100%;
        justify-content: center;
        font-size: 0.9rem;
    }
    .header-nav {
        width: 100%;
        justify-content: center;
        gap: 6px;
    }
    .header-nav a { font-size: 0.72rem; padding: 5px 8px; }
    /* Sembunyikan teks nama user di header HP agar tidak penuh */
    .header-nav > span { display: none; }

    .container { padding: 16px 12px; }
    
    /* Form menumpuk ke bawah */
    .form-row { flex-direction: column; gap: 12px; }
    .form-group.grow { min-width: 100%; }
    .form-row .btn { width: 100%; justify-content: center; padding: 12px; }
    .form-row .form-group { width: 100%; }

    /* Stats Grid 2 kolom */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; gap: 10px; }
    .stat-icon { width: 40px; height: 40px; border-radius: 10px; }
    .stat-icon svg { width: 20px; height: 20px; }
    .stat-value { font-size: 1.2rem; }

    /* Table Area */
    .table-top-bar, .pagination-wrapper { flex-direction: column; align-items: stretch; }
    .table-top-left { width: 100%; }
    .table-search { width: 100%; }
    .pagination { justify-content: center; margin-top: 8px; }

    .card-body { padding: 16px; }
    
    /* Tabel scroll horizontal tanpa merusak layar */
    .table-responsive { margin: 0 -16px; width: calc(100% + 32px); padding: 0; }
    .data-table thead th, .data-table tbody td { padding: 10px 14px; font-size: 0.82rem; }
    .hide-mobile { display: none !important; }

    /* Admin Inline Password */
    .inline-pw-wrapper input { width: 100px; }

    /* Modal & Toast */
    .modal-card { padding: 24px 20px; }
    .toast { max-width: 280px; font-size: 0.82rem; padding: 12px 16px; }
    .toast-container { right: 10px; top: 70px; }
}

@media (max-width: 480px) {
    /* Layar sangat kecil (iPhone SE, dll) */
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 30px 20px; border-radius: 18px; }
}