/* --- 1. RESET & VARIABLE --- */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

:root {
    --primary: #00b894;
    --primary-dark: #00a884;
    --primary-gradient: linear-gradient(135deg, #00b894, #00cec9);
    --secondary: #2d3436;
    --bg-color: #f1f2f6;
    --white: #ffffff;
    --danger: #ff7675;
    --sidebar-width: 250px;
    --mobile-nav-height: 65px;
    --shadow: 0 8px 24px rgba(0,0,0,0.08);
    --safe-bottom: env(safe-area-inset-bottom);
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    margin: 0; padding: 0;
    color: var(--secondary);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* --- HEADER & JAM REALTIME --- */
.header-welcome {
    margin-bottom: 25px;
    position: relative; 
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.greeting-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-welcome h2 {
    margin: 0;
    font-size: 22px;
    color: var(--secondary);
}

.header-welcome p {
    margin: 0;
    color: #636e72;
    font-size: 13px;
    text-align: right;
}

/* Style Jam */
.clock-badge {
    background: #dfe6e9;
    color: #2d3436;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: monospace;
    letter-spacing: 0.5px;
}

@media (min-width: 769px) {
    .clock-badge {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        background: white;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
        font-size: 16px;
        padding: 8px 15px;
        border-radius: 12px;
    }
}

/* --- TOMBOL DATA MANAGEMENT --- */
.data-management {
    margin-top: 30px;
    padding: 20px;
    background: white;
    border-radius: 18px;
    box-shadow: var(--shadow);
    text-align: center;
}
.data-management h4 { margin: 0 0 15px 0; color: var(--secondary); }
.btn-group-data { display: flex; gap: 10px; justify-content: center; margin-bottom: 15px; }

.btn-data {
    border: none; padding: 10px 15px; border-radius: 10px;
    font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 13px;
}
.btn-backup { background: #00b894; color: white; }
.btn-restore { background: #0984e3; color: white; }
.btn-reset-link { background: none; border: none; color: #ff7675; text-decoration: underline; cursor: pointer; font-size: 12px; }

/* --- CSS LAMA --- */
.install-banner {
    display: none; position: fixed; top: 0; left: 0; right: 0;
    background: #2d3436; color: white; padding: 12px 20px;
    z-index: 9999; align-items: center; justify-content: space-between;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    animation: slideDown 0.5s ease;
}
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }
.install-content { display: flex; align-items: center; gap: 15px; }
.install-content i { font-size: 20px; color: var(--primary); }
.install-content div { display: flex; flex-direction: column; }
.install-content strong { font-size: 14px; }
.install-content span { font-size: 11px; opacity: 0.8; }
.btn-install { background: var(--primary); border: none; padding: 6px 15px; border-radius: 20px; color: white; font-weight: bold; cursor: pointer; margin-right: 10px; font-size: 12px; }
.btn-close-banner { background: transparent; border: none; color: white; cursor: pointer; font-size: 16px; }

.sidebar { width: var(--sidebar-width); background: var(--white); display: flex; flex-direction: column; padding: 30px; height: 100%; border-right: 1px solid #dfe6e9; z-index: 50; flex-shrink: 0; }
.logo { font-size: 22px; font-weight: 800; margin-bottom: 40px; background: var(--primary-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; display: flex; align-items: center; gap: 10px; }
.nav-item { padding: 15px; margin-bottom: 8px; border-radius: 12px; cursor: pointer; display: flex; align-items: center; gap: 15px; color: #b2bec3; font-weight: 500; transition: 0.3s; }
.nav-item:hover { background: #f5f6fa; color: var(--secondary); }
.nav-item.active { background: var(--primary-gradient); color: white; box-shadow: 0 5px 15px rgba(0,184,148,0.3); }

.main-content { flex: 1; overflow-y: auto; padding: 30px; position: relative; height: 100%; padding-bottom: 100px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-bottom: 25px; }
.stat-card { background: white; padding: 20px; border-radius: 18px; position: relative; overflow: hidden; box-shadow: var(--shadow); height: 140px; display: flex; flex-direction: column; justify-content: space-between; }
.card-balance { background: var(--primary-gradient); color: white; }
.card-expense { border-left: 5px solid #ff7675; }
.card-income { border-left: 5px solid #0984e3; }
.stat-info h3 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.9; }
.stat-info p { margin: 5px 0 0; font-size: 24px; font-weight: 700; }
.icon-bg { position: absolute; right: -10px; bottom: -10px; font-size: 80px; opacity: 0.1; transform: rotate(-10deg); }
.btn-topup-mini { background: rgba(255,255,255,0.3); border: none; color: white; padding: 3px 10px; border-radius: 10px; font-size: 10px; cursor: pointer; margin-left: 8px; }

.chart-box { background: white; padding: 20px; border-radius: 18px; box-shadow: var(--shadow); margin-bottom: 30px; }
.chart-wrapper { position: relative; height: 250px; width: 100%; }
.form-box { background: white; padding: 25px; border-radius: 18px; box-shadow: var(--shadow); max-width: 500px; margin: 0 auto; }
.input-group { margin-bottom: 15px; }
.input-group label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: #636e72; }
input, select { width: 100%; padding: 12px; border: 2px solid #f1f2f6; border-radius: 10px; font-size: 14px; transition: 0.3s; }
input:focus, select:focus { border-color: var(--primary); background: #fff; }
.btn-save { width: 100%; padding: 14px; border: none; border-radius: 12px; background: var(--primary-gradient); color: white; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 10px; box-shadow: 0 4px 15px rgba(0,184,148,0.3); }

.table-container { background: white; padding: 0; border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
td { padding: 15px; border-bottom: 1px solid #f9f9f9; vertical-align: middle; }
.cat-badge { padding: 3px 8px; background: #f1f2f6; border-radius: 6px; font-size: 10px; color: #636e72; margin-left: 5px; }

#toast { visibility: hidden; min-width: 200px; background: #2d3436; color: #fff; text-align: center; border-radius: 50px; padding: 10px 20px; position: fixed; z-index: 2000; left: 50%; transform: translateX(-50%); bottom: 80px; font-size: 13px; opacity: 0; transition: opacity 0.3s, bottom 0.3s; }
#toast.show { visibility: visible; opacity: 1; bottom: 100px; }
.page { display: none; opacity: 0; animation: fadeIn 0.3s forwards; }
.page.active { display: block; }
@keyframes fadeIn { to { opacity: 1; } }

/* MOBILE RESPONSIVE */
@media (max-width: 768px) {
    body { flex-direction: column; height: 100vh; overflow: hidden; }
    .sidebar { position: fixed; bottom: 0; left: 0; width: 100%; height: calc(var(--mobile-nav-height) + var(--safe-bottom)); padding: 0; padding-bottom: var(--safe-bottom); flex-direction: row; justify-content: space-around; border-top: 1px solid #eee; border-right: none; border-radius: 20px 20px 0 0; box-shadow: 0 -5px 20px rgba(0,0,0,0.05); z-index: 1000; }
    .logo { display: none; }
    .nav-item { flex-direction: column; gap: 4px; margin: 0; border-radius: 0; background: transparent !important; color: #b2bec3; flex: 1; justify-content: center; box-shadow: none !important; }
    .nav-item.active { color: var(--primary) !important; }
    .nav-item i { font-size: 18px; margin-bottom: 2px; }
    .nav-item span { font-size: 10px; font-weight: 500; }
    .main-content { height: 100%; padding: 20px; padding-bottom: 90px; overflow-y: auto; }
    .card-grid { grid-template-columns: 1fr; gap: 15px; }
    .stat-card { height: 130px; }
    .install-banner { padding: 10px 15px; }
    .install-content strong { font-size: 13px; }
    .btn-save { position: fixed; bottom: 80px; left: 5%; width: 90%; z-index: 900; box-shadow: 0 5px 20px rgba(0,0,0,0.2); }
    #input.page { padding-bottom: 140px; }
    
    .header-welcome { flex-direction: column; align-items: flex-start; gap: 5px; }
    .header-welcome p { text-align: left; }
    .greeting-area { width: 100%; justify-content: space-between; }
}

/* --- FITUR DRAG & DROP STYLE --- */
.drag-handle {
    cursor: grab;
    color: #dfe6e9;
    padding: 10px 5px;
    font-size: 16px;
    transition: 0.2s;
}
.drag-handle:hover { color: var(--primary); }
.sortable-ghost { background-color: #f1f2f6; opacity: 0.5; border: 2px dashed #b2bec3; }

#listData tr td:first-child {
    display: flex; 
    align-items: center;
    border-bottom: none; 
}
#listData tr { border-bottom: 1px solid #f9f9f9; }

/* --- STYLE TOMBOL AKSI (BARU) --- */
.action-btn-group {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 5px;
}

.action-btn {
    font-size: 16px;
    cursor: pointer;
    transition: 0.2s;
}

.btn-edit { color: #f1c40f; } /* Kuning Pensil */
.btn-delete { color: #dfe6e9; } /* Abu-abu default */
.btn-delete:hover { color: #ff7675; }

/* --- HEADER STYLE (TOMBOL TEMA) --- */
.greeting-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.btn-theme {
    background: white; 
    border: 1px solid #dfe6e9;
    color: #2d3436;
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: 0.2s;
    position: relative; 
    z-index: 10;
}

/* MOBILE FIX */
@media (max-width: 768px) {
    .greeting-wrapper {
        flex-direction: row; 
        justify-content: space-between;
        align-items: center;
        margin-bottom: 5px;
    }
    .title-row h2 { font-size: 18px; }
    .header-welcome { display: flex; flex-direction: column; }
    .clock-badge { font-size: 11px; padding: 3px 8px; }
}

/* =========================================
   DARK MODE STYLES
   ========================================= */
body.dark-mode {
    background-color: #121212; 
    color: #dfe6e9;
}

body.dark-mode .sidebar,
body.dark-mode .stat-card,
body.dark-mode .chart-box,
body.dark-mode .form-box,
body.dark-mode .table-container,
body.dark-mode .data-management,
body.dark-mode .install-banner {
    background-color: #1e1e1e;
    color: #dfe6e9;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

body.dark-mode .sidebar { border-right: 1px solid #333; }
body.dark-mode td { border-bottom: 1px solid #333; }
body.dark-mode .header-welcome h2 { color: #fff; }
body.dark-mode .header-welcome p { color: #b2bec3; }

body.dark-mode input, 
body.dark-mode select {
    background-color: #2d2d2d;
    border-color: #444;
    color: #fff;
}
body.dark-mode input:focus, 
body.dark-mode select:focus {
    border-color: var(--primary);
    background-color: #333;
}

body.dark-mode .nav-item { color: #b2bec3; }
body.dark-mode .nav-item:hover { background-color: #2d2d2d; color: #fff; }
body.dark-mode .stat-info h3 { color: #b2bec3; }
body.dark-mode .sortable-ghost { background-color: #333; border-color: #555; }
body.dark-mode .clock-badge { background-color: #2d2d2d; color: #fff; }
body.dark-mode .btn-theme { background: #2d2d2d; border-color: #444; color: #ffd700; }

@media (max-width: 768px) {
    body.dark-mode .sidebar {
        background-color: #1e1e1e;
        border-top: 1px solid #333;
    }
}

body.dark-mode #listData td div:first-child { color: #ffffff !important; }
body.dark-mode #listData td div:last-child { color: #dcdde1 !important; }
body.dark-mode .cat-badge { background-color: #2d3436; color: #dfe6e9; border: 1px solid #636e72; }

/* Warna Tombol Aksi di Dark Mode */
body.dark-mode .btn-edit { color: #f1c40f !important; }
body.dark-mode .btn-delete { color: #ff7675 !important; }

/* Border Putih Tipis Dark Mode */
body.dark-mode .btn-theme,      
body.dark-mode .btn-topup-mini,
body.dark-mode .btn-save,       
body.dark-mode .btn-data,       
body.dark-mode .btn-install,    
body.dark-mode .btn-close-banner
{
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

body.dark-mode .btn-theme { border-color: rgba(255, 255, 255, 0.5) !important; }

body.dark-mode .btn-theme:hover,
body.dark-mode .btn-topup-mini:hover,
body.dark-mode .btn-data:hover {
    border-color: #ffffff !important;
}

body.dark-mode input, 
body.dark-mode select {
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}