/* ============================================================
   Kalkulator WhatsApp — style.css  v7
   Mode: Standar (Kalkulator + Persen) | Riwayat
   WhatsApp History Tab View
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html {
    /* Hindari auto-zoom aneh & pastikan tap terasa responsif di mobile */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #dddbd1;
    padding: 20px;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
}

/* ── Container ─────────────────────────────────────────────── */
.wa-container {
    background-color: #ece5dd00;
    background-image: url('assets/img/whatsapp.jpg');
    background-repeat: repeat;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Sidebar (WhatsApp Web) — disembunyikan secara default, hanya untuk desktop ── */
.wa-sidebar { display: none; }
.wa-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }

/* ── Header ────────────────────────────────────────────────── */
.wa-header {
    background-color: #075e54;
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.wa-header-info { display: flex; align-items: center; gap: 12px; flex: 1; }
.wa-avatar {
    width: 40px; height: 40px; min-width: 40px;
    background: #fff; border-radius: 50%;
    display: flex; justify-content: center; align-items: center; font-size: 20px;
}
.wa-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.wa-status { font-size: 12px; color: #cfd8dc; }

/* ── Language Switch ─────────────────────────────────────── */
.wa-lang-switch {
    display: flex;
    gap: 3px;
    background: rgba(255,255,255,0.14);
    border-radius: 20px;
    padding: 3px;
    flex-shrink: 0;
}
.wa-lang-btn {
    border: none;
    background: transparent;
    color: #cfd8dc;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .2px;
    padding: 6px 10px;
    border-radius: 16px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}
.wa-lang-btn:hover { color: #fff; }
.wa-lang-btn.active {
    background: #fff;
    color: #075e54;
}

/* ── Chat Body ─────────────────────────────────────────────── */
.wa-chat-body { padding: 16px; display: flex; flex-direction: column; }

/* ── Mode Dropdown (Modern) ───────────────────────────────── */
.mode-select-wrapper {
    position: relative;
    margin-bottom: 14px;
}
.mode-select {
    width: 100%;
    height: 50px;
    background: linear-gradient(135deg, #17a190 0%, #0b6e60 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    border: none;
    border-radius: 14px;
    padding: 0 44px 0 18px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    text-align: left;
    letter-spacing: .2px;
    background-image: none;
    box-shadow:
        0 4px 14px rgba(7, 64, 56, 0.32),
        inset 0 1px 0 rgba(255,255,255,0.18);
    transition: box-shadow 0.2s ease, transform 0.12s ease, background 0.2s ease;
}
.mode-select:hover {
    box-shadow:
        0 6px 18px rgba(7, 64, 56, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.22);
}
.mode-select:active { transform: scale(0.99); }
.mode-select:focus {
    outline: none;
    box-shadow:
        0 0 0 3px rgba(37, 217, 183, 0.35),
        0 4px 14px rgba(7, 64, 56, 0.32);
}
.mode-select option { color: #2b2b2b; background: #fff; font-weight: 600; }

/* Panah custom (dibuat dari border, bukan SVG) — berputar saat fokus/terbuka */
.mode-select-arrow {
    position: absolute;
    top: 50%;
    right: 18px;
    width: 9px;
    height: 9px;
    border-right: 2.5px solid rgba(255,255,255,0.95);
    border-bottom: 2.5px solid rgba(255,255,255,0.95);
    border-radius: 0 0 2px 0;
    transform: translateY(-65%) rotate(45deg);
    pointer-events: none;
    transition: transform 0.25s ease;
}
.mode-select-wrapper:has(.mode-select:focus) .mode-select-arrow {
    transform: translateY(-35%) rotate(225deg);
}

/* ── Petunjuk ──────────────────────────────────────────────── */
.wa-petunjuk {
    background: #ffeecd; color: #514633; font-size: 11.5px;
    padding: 5px 12px; border-radius: 6px;
    align-self: center; text-align: center; margin: 0 0 14px;
}

/* ── Mode Hint ─────────────────────────────────────────────── */
.mode-hint {
    font-size: 12px; color: #777;
    text-align: center; margin: -4px 0 12px;
    background: #f0f0f0; border-radius: 6px; padding: 5px 10px;
}

/* ── Tab Donasi ────────────────────────────────────────────── */
.wa-donasi-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.donasi-header {
    text-align: center;
    padding: 20px 15px;
    background: linear-gradient(135deg, #075e54 0%, #128c7e 100%);
    border-radius: 10px;
    color: white;
}

.donasi-icon {
    font-size: 48px;
    margin-bottom: 12px;
    animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.donasi-header h3 {
    margin: 10px 0 5px;
    font-size: 24px;
    font-weight: 700;
}

.donasi-subtitle {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.donasi-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

@media (min-width: 768px) {
    .donasi-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

.donasi-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #e0e0e0;
}

.donasi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.donasi-card-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.donasi-card h4 {
    margin: 12px 0 8px;
    font-size: 18px;
    color: #075e54;
    font-weight: 700;
}

.donasi-card p {
    margin: 0 0 16px;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.donasi-btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.donasi-btn-primary {
    background: linear-gradient(135deg, #075e54 0%, #128c7e 100%);
    color: white;
}

.donasi-btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(7, 94, 84, 0.3);
}

.donasi-btn-secondary {
    background: linear-gradient(135deg, #ffa500 0%, #ff8c00 100%);
    color: white;
}

.donasi-btn-secondary:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 165, 0, 0.3);
}

.donasi-btn-success {
    background: linear-gradient(135deg, #e91e63 0%, #c2185b 100%);
    color: white;
}

.donasi-btn-success:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(233, 30, 99, 0.3);
}

.donasi-message {
    background: #f0f0f0;
    border-left: 4px solid #075e54;
    padding: 15px;
    border-radius: 6px;
    text-align: center;
    font-size: 13px;
    color: #555;
    line-height: 1.6;
}

.donasi-message p {
    margin: 0;
}

/* ── Grid Input (Standar) ──────────────────────────────────── */
.input-group { display: flex; flex-direction: column; }
.input-group-op { flex: 0 0 64px; }
.input-group label { font-size: 11px; color: #128c7e; margin-bottom: 4px; font-weight: 600; }

input, select {
    padding: 9px 10px; border: 1.5px solid #0a2e29; border-radius: 8px;
    text-align: right; outline: none; font-size: 16px; width: 100%;
    height: 46px;
    -webkit-appearance: none; appearance: none;
    font-family: 'Courier New', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 700; letter-spacing: 0.5px;
    background: linear-gradient(165deg, #0f4a41, #0b3d36);
    color: #d6fff1;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.35), inset 0 -1px 0 rgba(255,255,255,0.04);
    transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
input::placeholder { color: #5fa195; opacity: 0.75; font-weight: 600; }
select {
    text-align: center; cursor: pointer; font-weight: 800;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2325d9b7' d='M5 6L0 0h10z'/%3E%3C/svg%3E"),
        linear-gradient(165deg, #0f4a41, #0b3d36);
    background-repeat: no-repeat, no-repeat;
    background-position: center right 10px, 0 0;
    background-size: auto, 100% 100%;
    padding-right: 24px;
}
/* Opsi di dalam dropdown selalu dirender native oleh browser dengan latar putih,
   jadi warna teksnya harus gelap agar tidak "hilang" (mewarisi warna select yang terang) */
select option {
    color: #0a2e29;
    background: #fff;
    font-weight: 700;
}
input:focus, select:focus {
    border-color: #25d9b7; background: linear-gradient(165deg, #115b50, #0d473e);
    color: #fff;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.35), 0 0 0 3px rgba(37,217,183,0.25);
}
select:focus {
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2325d9b7' d='M5 6L0 0h10z'/%3E%3C/svg%3E"),
        linear-gradient(165deg, #115b50, #0d473e);
    background-repeat: no-repeat, no-repeat;
    background-position: center right 10px, 0 0;
    background-size: auto, 100% 100%;
}

/* ── Kalkulator Standar (bebas, seperti kalkulator pada umumnya) ── */
.std-kalkulator {
    background: white; padding: 14px; border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1); margin-bottom: 10px;
    outline: none;
}
.std-layar {
    background: #0b3d36; border-radius: 8px;
    padding: 14px 16px 12px; margin-bottom: 12px;
    display: flex; flex-direction: column; align-items: flex-end;
    min-height: 78px; justify-content: center;
}
.std-ekspresi {
    color: #8fd6c9; font-size: 13px; min-height: 16px;
    margin-bottom: 4px; white-space: nowrap; overflow-x: auto;
    max-width: 100%;
}
.std-display {
    color: #fff; font-size: 32px; font-weight: 600;
    line-height: 1.1; word-break: break-all; text-align: right;
    width: 100%;
}
.std-keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.std-key {
    border: none; border-radius: 8px; background: #f0f0f0; color: #2b2b2b;
    font-size: 19px; font-weight: 600; cursor: pointer;
    height: 52px; transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.std-key:hover { background: #e2e2e2; }
.std-key:active { transform: scale(0.95); }
.std-key-fn { background: #d7ecea; color: #0b5e54; }
.std-key-fn:hover { background: #c5e3df; }
.std-key-op { background: #128c7e; color: #fff; }
.std-key-op:hover { background: #0e6e63; }
.std-key-eq { background: #075e54; color: #fff; }
.std-key-eq:hover { background: #054a42; }

@media (max-width: 480px) {
    .std-display { font-size: 28px; }
    .std-key { height: 48px; font-size: 18px; }
}
@media (max-width: 360px) {
    .std-layar { padding: 12px 12px 10px; }
    .std-display { font-size: 24px; }
    .std-keypad { gap: 6px; }
    .std-key { height: 44px; font-size: 16px; }
}


.single-col-grid {
    display: flex; flex-direction: column; gap: 12px;
    background: #fff; padding: 16px; border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08); margin-bottom: 10px;
    border: 1px solid #f0f0f0;
}

/* ── Persen / Sub-Tabs (Gaya Modern WhatsApp) ── */
.persen-mode-tabs, .pangkat-mode-tabs {
    display: flex; 
    gap: 0;
    flex-wrap: wrap; 
    margin-bottom: 14px;
    background: #f5f5f5;
    border-radius: 12px;
    padding: 4px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.persen-tab {
    flex: 1; 
    min-width: 70px;
    padding: 10px 12px;
    min-height: 42px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #666;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.3px;
    line-height: 1.2;
}

.persen-tab::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(37, 217, 183, 0);
    border-radius: 10px;
    transition: background 0.25s ease;
    pointer-events: none;
}

.persen-tab:hover {
    background: rgba(37, 217, 183, 0.1);
    color: #0b6e60;
}

.persen-tab:hover::before {
    background: rgba(37, 217, 183, 0.08);
}

.persen-tab:active {
    transform: scale(0.98);
}

.persen-tab.active {
    background: linear-gradient(135deg, #25d9b7 0%, #128c7e 100%);
    color: #fff;
    font-weight: 700;
    box-shadow: 
        0 4px 12px rgba(18, 140, 126, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.persen-tab.active::before {
    background: rgba(255, 255, 255, 0.1);
}

/* Animasi entrance untuk tab */
@keyframes tabSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.persen-tab {
    animation: tabSlideIn 0.4s ease backwards;
}

.persen-tab:nth-child(1) { animation-delay: 0.05s; }
.persen-tab:nth-child(2) { animation-delay: 0.1s; }
.persen-tab:nth-child(3) { animation-delay: 0.15s; }
.persen-tab:nth-child(4) { animation-delay: 0.2s; }

/* Mobile responsive */
@media (max-width: 480px) {
    .persen-mode-tabs, .pangkat-mode-tabs {
        gap: 0;
        padding: 3px;
    }
    
    .persen-tab {
        padding: 8px 10px;
        min-height: 40px;
        font-size: 11px;
    }
}

@media (max-width: 360px) {
    .persen-tab {
        padding: 8px 8px;
        min-height: 38px;
        font-size: 10px;
        min-width: 60px;
    }
}

/* ── Satuan (Konversi) ──────────────────────────────────────── */
.satuan-field {
    display: flex;
    gap: 8px;
}
.satuan-field input { flex: 1.3; min-width: 0; }
.satuan-field select { flex: 1; min-width: 0; }

.satuan-swap-wrap {
    display: flex;
    justify-content: center;
    margin: -4px 0;
}
.satuan-swap-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #25d9b7 0%, #128c7e 100%);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(18, 140, 126, 0.35);
    transition: transform 0.25s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.satuan-swap-btn:hover {
    box-shadow: 0 4px 12px rgba(18, 140, 126, 0.45);
}
.satuan-swap-btn:active {
    transform: scale(0.9) rotate(180deg);
}

@media (max-width: 360px) {
    .satuan-field { gap: 6px; }
    .satuan-swap-btn { width: 34px; height: 34px; min-width: 34px; font-size: 16px; }
}

/* ── Catatan (Notes) Container ─────────────────────────────── */
.catatan-container {
    background: #fff;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 10px;
}

.catatan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
}

.catatan-header h4 {
    margin: 0;
    color: #128c7e;
    font-size: 15px;
    font-weight: 700;
}

.btn-refresh-catatan {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #128c7e;
    transition: transform 0.2s ease;
    padding: 0;
}

.btn-refresh-catatan:hover {
    transform: rotate(20deg);
}

.catatan-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
}

.catatan-item {
    padding: 10px;
    background: #f9f9f9;
    border-left: 3px solid #128c7e;
    border-radius: 4px;
    font-size: 13px;
}

.catatan-item-text {
    color: #333;
    margin-bottom: 4px;
}

.catatan-item-time {
    color: #999;
    font-size: 11px;
}

/* ── Action Buttons (Hitung + Reset) ───────────────────────── */
.wa-action-buttons {
    display: flex; gap: 10px; margin-bottom: 12px;
}
.btn-hitung, .btn-reset {
    flex: 1; height: 44px;
    border: none; border-radius: 8px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.btn-hitung {
    background: linear-gradient(135deg, #0f8d78, #075e54);
    color: #fff;
    box-shadow: 0 2px 8px rgba(7,94,84,0.3);
}
.btn-hitung:hover { box-shadow: 0 4px 12px rgba(7,94,84,0.4); }
.btn-hitung:active { transform: scale(0.98); }

.btn-reset {
    background: #f0f0f0; color: #555;
    border: 1.5px solid #ddd;
}
.btn-reset:hover { background: #e8e8e8; }
.btn-reset:active { transform: scale(0.98); }

/* ── Bubble Hasil ──────────────────────────────────────────── */
.wa-bubble-container {
    display: flex; gap: 4px; margin-bottom: 0;
    justify-content: flex-end; padding: 0 4px;
}
.wa-bubble-hasil {
    background: #dcf8c6; padding: 10px 15px;
    border-radius: 8px 0 8px 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    max-width: 85%; min-width: 140px;
    position: relative; text-align: right;
}
.wa-label-hasil { font-size: 11px; color: #557a3a; display: block; text-align: left; font-weight: 600; margin-bottom: 4px; }
.wa-bubble-hasil h1 { margin: 4px 0 18px; font-size: 26px; color: #303030; word-break: break-all; }

/* Hasil multi-baris (persen) */
.hasil-multi-row {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 12px; padding: 3px 0;
}
.hasil-multi-label { font-size: 11px; color: #557a3a; font-weight: 600; white-space: nowrap; }
.hasil-multi-val { font-size: 16px; font-weight: 700; color: #1a1a1a; text-align: right; }
.wa-bubble-hasil .hasil-multi-row:last-child { margin-bottom: 14px; }

.wa-time { font-size: 10px; color: #72965a; position: absolute; bottom: 5px; right: 8px; }

/* ── Riwayat Dropdown ──────────────────────────────────────── */
.wa-history-section {
    border-top: 1px dashed #ccc; padding-top: 14px;
    display: flex; flex-direction: column;
}

.wa-history-dropdown {
    border: 1px solid #ddd;
    border-radius: 10px;
    background-color: #f9f9f9;
    overflow: hidden;
}

.wa-history-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    background: linear-gradient(135deg, #f5f5f5 0%, #efefef 100%);
    font-weight: 600;
    color: #333;
    user-select: none;
    transition: background 0.2s ease;
    list-style: none;
}

.wa-history-summary:hover {
    background: linear-gradient(135deg, #efefef 0%, #e9e9e9 100%);
}

.wa-history-summary::before {
    content: '▶';
    display: inline-block;
    transition: transform 0.2s ease;
    font-size: 12px;
    color: #555;
}

.wa-history-dropdown[open] .wa-history-summary::before {
    transform: rotate(90deg);
}

.wa-history-icon {
    font-size: 16px;
}

.wa-history-label {
    flex: 1;
    font-size: 14px;
}

.wa-history-count {
    font-size: 12px;
    color: #888;
    font-weight: normal;
}

.btn-clear-all-summary {
    background: none;
    border: none;
    color: #d9534f;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    padding: 0;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.btn-clear-all-summary:hover {
    color: #c9302c;
}

.wa-history-list {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
    border-top: 1px solid #e0e0e0;
    background-color: #fff;
}

.wa-bubble-history {
    background: #f0f0f0;
    padding: 8px 28px 8px 12px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    align-self: flex-start;
    max-width: 100%;
    position: relative;
    font-size: 13px;
    animation: fadeIn 0.25s ease;
    word-break: break-word;
}

.wa-history-text {
    color: #555;
    display: block;
    margin-bottom: 4px;
}

.wa-history-total {
    color: #000;
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.wa-history-time {
    font-size: 9px;
    color: #999;
    vertical-align: bottom;
}

.btn-delete-item {
    position: absolute;
    right: 0;
    top: 0;
    background: none;
    border: none;
    color: #bbb;
    font-size: 16px;
    cursor: pointer;
    padding: 8px 10px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.btn-delete-item:hover {
    color: #ff3333;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive Mobile ─────────────────────────────────────── */
@media (max-width: 480px) {
    body { padding: 0; align-items: flex-start; background: #ece5dd; }
    .wa-container { border-radius: 0; min-height: 100vh; min-height: 100dvh; max-width: 100%; }
    .wa-chat-body { flex: 1; padding: 12px; }

    .wa-header { padding: 10px 12px; }
    .wa-header h3 { font-size: 14.5px; }
    .wa-status { font-size: 11px; }
    .wa-avatar { width: 36px; height: 36px; min-width: 36px; font-size: 18px; }
    .wa-lang-btn { font-size: 10px; padding: 5px 8px; }

    /* Standar: tumpuk vertikal, operator full width di tengah */
    .input-group-op { flex: 1; }
    .input-group-op select { max-width: 120px; margin: 0 auto; }

    .mode-select { font-size: 13px; padding: 0 38px 0 14px; height: 46px; }
    .mode-select-arrow { right: 15px; }

    .single-col-grid { padding: 12px; }

    .wa-bubble-hasil h1 { font-size: 22px; }
    .hasil-multi-val { font-size: 15px; }

    .wa-action-buttons button { font-size: 14px; padding: 12px; }
}

/* Layar sangat sempit (mis. iPhone SE, ~360px atau kurang) */
@media (max-width: 360px) {
    .wa-chat-body { padding: 10px; }
    .wa-bubble-hasil h1 { font-size: 19px; }
    .wa-bubble-hasil { min-width: 0; }
    .hasil-multi-row { gap: 8px; }
    .mode-select { font-size: 12.5px; height: 44px; }
}

/* ── History Tab (Full View) ───────────────────────────────── */
.wa-history-full {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.wa-history-empty {
    text-align: center;
    padding: 40px 20px;
    color: #8a8a8a;
    font-size: 16px;
    font-weight: 500;
}

.wa-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #dcd8d5;
    gap: 12px;
    flex-wrap: wrap;
}

.wa-history-count {
    font-size: 14px;
    color: #75757a;
    font-weight: 500;
    min-width: 80px;
}

.wa-history-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-history-action {
    background: linear-gradient(135deg, #17a190, #0b6e60);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn-history-action:hover {
    box-shadow: 0 2px 8px rgba(7, 94, 84, 0.3);
}

.btn-history-action:active {
    transform: scale(0.95);
}

.btn-clear-all {
    background: none;
    border: none;
    color: #d9534f;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    padding: 8px 12px;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.btn-clear-all:hover {
    color: #c9302c;
}

.btn-drive {
    background: linear-gradient(135deg, #4285f4, #1a73e8);
}

.btn-drive-connected {
    background: linear-gradient(135deg, #34a853, #1e7e34);
}

.drive-info {
    font-size: 12px;
    color: #1565c0;
    background: #e8f0fe;
    border-left: 3px solid #4285f4;
    padding: 8px 12px;
    border-radius: 6px;
    margin: 8px 0;
}

.sync-status {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    margin: 10px 0;
    text-align: center;
    animation: slideDown 0.3s ease;
}

.sync-status.success {
    background: #c8e6c9;
    color: #2e7d32;
    border-left: 3px solid #2e7d32;
}

.sync-status.error {
    background: #ffcdd2;
    color: #c62828;
    border-left: 3px solid #c62828;
}

.sync-status.info {
    background: #bbdefb;
    color: #1565c0;
    border-left: 3px solid #1565c0;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wa-history-full-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 450px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
}

/* Layar pendek (landscape ponsel / area terbatas tinggi) */
@media (max-height: 600px) and (orientation: landscape) {
    body { align-items: flex-start; }
    .wa-history-list { max-height: 120px; }
    .wa-history-full-list { max-height: 200px; }
}

/* ── Standalone PWA ────────────────────────────────────────── */
@media (display-mode: standalone) {
    body { padding: 0; background: #075e54; align-items: flex-start; }
    .wa-container { border-radius: 0; min-height: 100vh; min-height: 100dvh; max-width: 100%; }
    .wa-header {
        padding-top: max(12px, env(safe-area-inset-top));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
}

/* ============================================================
   ══════════  TAMPILAN DESKTOP — ala WhatsApp Web  ══════════
   ============================================================ */
@media (min-width: 901px) {

    /* Backdrop khas WhatsApp Web: abu kehijauan gelap, app "mengambang" di tengah */
    body {
        background-color: #ffffff;
        background-image:
            linear-gradient(180deg, #00a884 0%, #00a884 130px, #f0f2f5 130px, #f0f2f5 100%);
        padding: 18px;
        align-items: center;
        justify-content: center;
    }

    /* Shell utama: jendela besar, dua kolom, seperti web.whatsapp.com */
    .wa-container {
        flex-direction: row;
        max-width: 1320px;
        width: 100%;
        height: min(820px, calc(100vh - 36px));
        background-color: #fff;
        background-image: none;
        border-radius: 8px;
        box-shadow: 0 8px 30px rgba(0,0,0,0.25);
        overflow: hidden;
    }

    /* ── Sidebar kiri: daftar "kontak" (mode kalkulator) ── */
    .wa-sidebar {
        display: flex;
        flex-direction: column;
        width: 360px;
        min-width: 320px;
        max-width: 420px;
        background: #fff;
        border-right: 1px solid #e9edef;
        flex-shrink: 0;
    }

    .wa-sidebar-header {
        height: 64px;
        min-height: 64px;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 0 16px;
        background: #f0f2f5;
        border-bottom: 1px solid #e9edef;
    }
    .wa-avatar-sidebar {
        width: 38px; height: 38px; min-width: 38px;
        background: #075e54; color: #fff;
        font-size: 18px;
    }
    .wa-sidebar-title {
        flex: 1;
        margin: 0;
        font-size: 15px;
        font-weight: 600;
        color: #111b21;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .wa-lang-switch-sidebar {
        background: #e9edef;
    }
    .wa-lang-switch-sidebar .wa-lang-btn {
        color: #54656f;
        font-size: 13px;
        padding: 5px 8px;
    }
    .wa-lang-switch-sidebar .wa-lang-btn.active {
        background: #fff;
        color: #075e54;
    }

    .wa-sidebar-search {
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 10px 12px;
        padding: 8px 12px;
        background: #f0f2f5;
        border-radius: 24px;
        color: #54656f;
    }
    .wa-sidebar-search-icon { font-size: 13px; }
    .wa-sidebar-search-text {
        font-size: 13.5px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .wa-sidebar-list {
        flex: 1;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }

    .wa-sidebar-item {
        display: flex;
        align-items: center;
        gap: 14px;
        width: 100%;
        border: none;
        background: transparent;
        padding: 12px 16px;
        cursor: pointer;
        text-align: left;
        border-bottom: 1px solid #f3f4f6;
        transition: background 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }
    .wa-sidebar-item:hover { background: #f5f6f6; }
    .wa-sidebar-item.active { background: #f0f2f5; }

    .wa-sidebar-item-avatar {
        width: 46px; height: 46px; min-width: 46px;
        border-radius: 50%;
        background: linear-gradient(135deg, #17a190, #0b6e60);
        display: flex; align-items: center; justify-content: center;
        font-size: 21px;
    }

    .wa-sidebar-item-info {
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
        overflow: hidden;
    }
    .wa-sidebar-item-info strong {
        font-size: 14.5px;
        color: #111b21;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .wa-sidebar-item-info small {
        font-size: 12.5px;
        color: #667781;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ── Panel kanan: "jendela chat" berisi kalkulator/riwayat ── */
    .wa-main {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        background-image: url('assets/img/whatsapp.jpg');
        background-repeat: repeat;
    }

    .wa-header {
        height: 64px;
        min-height: 64px;
        flex-shrink: 0;
        border-radius: 0;
    }

    .wa-chat-body {
        flex: 1;
        overflow-y: auto;
        padding: 24px 56px;
        display: flex;
        flex-direction: column;
    }

    /* Sembunyikan dropdown mode di mobile — di desktop navigasi pakai sidebar */
    .mode-select-wrapper { display: none; }

    .wa-petunjuk { align-self: center; }

    /* Lebarkan kalkulator standar agar nyaman dilihat di layar besar, tetap di tengah */
    .std-kalkulator {
        max-width: 380px;
        align-self: center;
        width: 100%;
    }
    .mode-hint { max-width: 380px; align-self: center; width: 100%; }

    .wa-history-full { max-width: 640px; align-self: center; width: 100%; }
    .wa-history-full-list { max-height: 100%; }

    /* Scrollbar tipis ala WhatsApp Web */
    .wa-sidebar-list::-webkit-scrollbar,
    .wa-chat-body::-webkit-scrollbar { width: 8px; }
    .wa-sidebar-list::-webkit-scrollbar-thumb,
    .wa-chat-body::-webkit-scrollbar-thumb {
        background: rgba(0,0,0,0.18);
        border-radius: 4px;
    }
}

@media (min-width: 1400px) {
    .wa-container { max-width: 1400px; }
}

/* ── Modern dark theme ─────────────────────────────────────── */
:root {
    color-scheme: dark;
    --dark-bg: #080d14;
    --dark-panel: #111923;
    --dark-panel-raised: #17222e;
    --dark-border: #253342;
    --dark-text: #e7eef5;
    --dark-muted: #93a4b5;
    --dark-accent: #35d6b0;
    --dark-accent-deep: #16a987;
}

body {
    background: radial-gradient(ellipse at 50% 0%, #142630 0%, var(--dark-bg) 58%);
    color: var(--dark-text);
}

.wa-container {
    background: var(--dark-panel);
    border: 1px solid var(--dark-border);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
}

.wa-main {
    background: var(--dark-bg);
    background-image: none;
}

.wa-header {
    background: #101923;
    border-bottom: 1px solid var(--dark-border);
}

.wa-avatar {
    background: #1b2a35;
    border: 1px solid #304451;
}

.wa-status { color: #9aabba; }

.wa-lang-switch {
    background: #1a2632;
    border: 1px solid #2b3a48;
}

.wa-lang-btn { color: #a7b5c2; }
.wa-lang-btn.active {
    background: var(--dark-accent);
    color: #08231e;
}

.wa-chat-body {
    background: var(--dark-bg);
}

.persen-mode-tabs,
.pangkat-mode-tabs {
    background: #111a24;
    border: 1px solid #1e2b37;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.22);
}

.persen-tab { color: #9aabba; }
.persen-tab:hover {
    background: rgba(53, 214, 176, 0.08);
    color: #8aefd5;
}
.persen-tab:hover::before { background: rgba(53, 214, 176, 0.04); }
.persen-tab.active {
    background: linear-gradient(135deg, #35d6b0, #16a987);
    color: #06251e;
    box-shadow: 0 5px 16px rgba(22, 169, 135, 0.22);
}

.wa-petunjuk,
.mode-hint {
    background: #111d27;
    border: 1px solid #243542;
    color: #a9bac7;
}

.std-kalkulator,
.single-col-grid,
.catatan-container {
    background: var(--dark-panel);
    border: 1px solid var(--dark-border);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.std-kalkulator { border-radius: 18px; padding: 16px; }
.std-layar {
    min-height: 96px;
    margin-bottom: 14px;
    padding: 16px;
    border: 1px solid #1c403f;
    border-radius: 13px;
    background: linear-gradient(145deg, #0c2528, #0b171e);
}
.std-ekspresi { color: #83b9af; }
.std-display { color: #f1fbf8; font-size: 36px; }

.std-key {
    background: #1b2733;
    color: #e2eaf0;
    border: 1px solid #283744;
    border-radius: 12px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16);
}
.std-key:hover { background: #253441; }
.std-key-fn {
    background: #1d3838;
    color: #76e2c7;
    border-color: #28504b;
}
.std-key-fn:hover { background: #264744; }
.std-key-op {
    background: #174a43;
    color: #8bf1d8;
    border-color: #21665a;
}
.std-key-op:hover { background: #206157; }
.std-key-eq {
    background: linear-gradient(145deg, #35d6b0, #16a987);
    color: #06251e;
    border-color: transparent;
    box-shadow: 0 5px 14px rgba(22, 169, 135, 0.2);
}
.std-key-eq:hover { background: #42e4bd; }

input,
select {
    border-color: #2a414a;
    background-color: #101d25;
    background-image: linear-gradient(165deg, #14252d, #101a22);
    color: #e1f6ef;
}
select:not(.mode-select) {
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2335d6b0' d='M5 6L0 0h10z'/%3E%3C/svg%3E"),
        linear-gradient(165deg, #14252d, #101a22);
    background-repeat: no-repeat, no-repeat;
    background-position: center right 10px, 0 0;
    background-size: auto, 100% 100%;
}
input::placeholder { color: #718d8a; }
input:focus,
select:focus {
    border-color: var(--dark-accent);
    background-image: linear-gradient(165deg, #183832, #122a28);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.25), 0 0 0 3px rgba(53, 214, 176, 0.15);
}
select:not(.mode-select):focus {
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2335d6b0' d='M5 6L0 0h10z'/%3E%3C/svg%3E"),
        linear-gradient(165deg, #183832, #122a28);
}
select option {
    background: #111923;
    color: var(--dark-text);
}
.input-group label { color: #75d8c0; }

.satuan-swap-btn,
.btn-hitung,
.btn-history-action:not(.btn-drive) {
    background: linear-gradient(135deg, #35d6b0, #16a987);
    color: #06251e;
}

.btn-reset {
    background: #1b2733;
    color: #c3ced8;
    border-color: #344452;
}
.btn-reset:hover { background: #253441; }

.wa-bubble-hasil {
    background: #16352f;
    border: 1px solid #28564b;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
}
.wa-label-hasil,
.hasil-multi-label { color: #94cbb9; }
.wa-bubble-hasil h1,
.hasil-multi-val { color: #e7f7f1; }
.wa-time { color: #83b7a5; }

.wa-history-section { border-color: var(--dark-border); }
.wa-history-dropdown {
    background: var(--dark-panel);
    border-color: var(--dark-border);
}
.wa-history-summary {
    background: #17222e;
    color: var(--dark-text);
}
.wa-history-summary:hover { background: #1d2b38; }
.wa-history-summary::before { color: var(--dark-accent); }
.wa-history-count { color: var(--dark-muted); }
.wa-history-list {
    background: #0e151d;
    border-color: var(--dark-border);
    scrollbar-color: #344756 transparent;
}
.wa-bubble-history,
.catatan-item {
    background: #17232d;
    border-color: #2c504b;
    box-shadow: none;
}
.wa-history-text,
.catatan-item-text { color: #bdcad4; }
.wa-history-total { color: #e7eef5; }
.wa-history-time,
.catatan-item-time { color: #8b9ba9; }
.wa-history-empty,
.wa-history-count { color: var(--dark-muted); }
.wa-history-header,
.catatan-header { border-color: var(--dark-border); }
.catatan-header h4,
.btn-refresh-catatan { color: var(--dark-accent); }

.donasi-card,
.donasi-message {
    background: var(--dark-panel);
    border-color: var(--dark-border);
    color: #bdcad4;
}
.donasi-card h4 { color: var(--dark-accent); }
.donasi-card p { color: var(--dark-muted); }

.drive-info,
.sync-status.success,
.sync-status.error,
.sync-status.info {
    background: #17232d;
    color: #c5d4de;
}
.drive-info { border-left-color: #62a4ff; }
.sync-status.success { color: #8de0a3; border-left-color: #47bd68; }
.sync-status.error { color: #ff9d9d; border-left-color: #ef6666; }
.sync-status.info { color: #91c4ff; border-left-color: #5c9dea; }

.mode-select:focus-visible,
.persen-tab:focus-visible,
.std-key:focus-visible,
.btn-hitung:focus-visible,
.btn-reset:focus-visible,
.wa-lang-btn:focus-visible {
    outline: 2px solid var(--dark-accent);
    outline-offset: 3px;
}

@media (min-width: 901px) {
    body {
        background: radial-gradient(ellipse at 50% 0%, #142630 0%, var(--dark-bg) 62%);
    }
    .wa-container { background: var(--dark-panel); }
    .wa-sidebar {
        background: #101923;
        border-color: var(--dark-border);
    }
    .wa-sidebar-header {
        background: #141f2a;
        border-color: var(--dark-border);
    }
    .wa-avatar-sidebar {
        background: #1b2a35;
        color: var(--dark-accent);
    }
    .wa-sidebar-title,
    .wa-sidebar-item-info strong { color: var(--dark-text); }
    .wa-sidebar-search {
        background: #1a2632;
        color: var(--dark-muted);
    }
    .wa-lang-switch-sidebar { background: #1a2632; }
    .wa-lang-switch-sidebar .wa-lang-btn { color: #a7b5c2; }
    .wa-lang-switch-sidebar .wa-lang-btn.active {
        background: var(--dark-accent);
        color: #08231e;
    }
    .wa-sidebar-item { border-color: #1d2934; }
    .wa-sidebar-item:hover,
    .wa-sidebar-item.active { background: #1a2632; }
    .wa-sidebar-item-info small { color: var(--dark-muted); }
    .wa-sidebar-list::-webkit-scrollbar-thumb,
    .wa-chat-body::-webkit-scrollbar-thumb { background: #344756; }
}

@media (max-width: 480px) {
    body { background: var(--dark-bg); }
    .wa-container { border: 0; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}