/* ============================================
   ROOT VARIABLES - LIGHT & DARK
   ============================================ */
:root {
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --text-primary: #1a2332;
    --text-secondary: #4a5a6e;
    --text-muted: #8a9aa8;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.10);
    --primary: #4f6ef7;
    --primary-dark: #3a56d4;
    --success: #22b573;
    --danger: #ef5a6b;
    --warning: #f5a623;
    --purple: #7c5cfc;
    --radius: 12px;
    --radius-sm: 8px;
    --input-bg: #f0f4f8;
    --hover-bg: #f0f4f8;
}

[data-theme="dark"] {
    --bg: #0f1420;
    --card-bg: #1a2332;
    --text-primary: #e8edf2;
    --text-secondary: #a0b0c0;
    --text-muted: #6a7a8e;
    --border: #2a3348;
    --shadow: 0 1px 3px rgba(0,0,0,0.40);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.60);
    --input-bg: #0f1420;
    --hover-bg: #253040;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    padding: 16px;
    padding-bottom: 80px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    transition: background 0.3s, box-shadow 0.3s;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-left h1 {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.header-sub {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    flex-shrink: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 4px 12px;
    border-radius: 16px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    transition: background 0.3s;
}

.theme-toggle {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--border);
}

/* ============================================
   PERMISSION BANNER
   ============================================ */
.permission-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #fef9e7;
    border: 1px solid #faeec9;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 500;
}

[data-theme="dark"] .permission-banner {
    background: #2a2330;
    border-color: #3a2a40;
    color: var(--text-secondary);
}

.permission-banner .btn {
    padding: 4px 14px;
    font-size: 11px;
}

/* ============================================
   QRIS UPLOAD SECTION
   ============================================ */
.qris-section {
    margin-bottom: 16px;
}

.qris-upload-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.qris-upload-box {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    transition: all 0.3s ease;
    background: var(--bg);
}

.qris-upload-box:hover {
    border-color: var(--primary);
    background: rgba(79, 110, 247, 0.05);
}

.qris-upload-box.dragover {
    border-color: var(--primary);
    background: rgba(79, 110, 247, 0.10);
}

.qris-upload-icon {
    font-size: 28px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.qris-upload-text {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
}

.qris-upload-hint {
    font-size: 10px;
    color: var(--text-muted);
    display: block;
    margin-top: 4px;
}

.qris-upload-btn {
    padding: 6px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 6px 0;
}

.qris-upload-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.qris-preview-container {
    position: relative;
    display: inline-block;
    margin: 0 auto;
    padding: 6px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
}

.qris-preview-image {
    max-width: 120px;
    max-height: 120px;
    display: block;
    border-radius: 4px;
}

.qris-remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.qris-remove-btn:hover {
    transform: scale(1.1);
}

.btn-qris {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-qris:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(79, 110, 247, 0.30);
}

/* ============================================
   SOUND UPLOAD SECTION - CUSTOM
   ============================================ */
.sound-upload-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}

.sound-upload-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.sound-upload-icon {
    font-size: 16px;
    color: var(--text-muted);
}

.sound-upload-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.sound-upload-box {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    transition: all 0.3s ease;
    background: var(--bg);
}

.sound-upload-box:hover {
    border-color: var(--primary);
    background: rgba(79, 110, 247, 0.05);
}

.sound-upload-box.dragover {
    border-color: var(--primary);
    background: rgba(79, 110, 247, 0.10);
}

.sound-upload-box .sound-upload-icon {
    font-size: 24px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.sound-upload-text {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
}

.sound-upload-hint {
    font-size: 10px;
    color: var(--text-muted);
    display: block;
    margin-top: 4px;
}

.sound-upload-btn {
    padding: 6px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 6px 0;
}

.sound-upload-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.sound-preview-container {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.sound-preview-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sound-play-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sound-play-btn:hover {
    transform: scale(1.05);
}

.sound-remove-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sound-remove-btn:hover {
    transform: scale(1.05);
}

.sound-default-info {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sound-default-label {
    font-weight: 600;
    color: var(--text-secondary);
}

/* ============================================
   SOUND SETTINGS
   ============================================ */
.sound-section {
    background: var(--card-bg);
    padding: 14px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}

.sound-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.sound-icon {
    font-size: 16px;
    color: var(--text-muted);
}

.sound-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.sound-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

.sound-btn {
    padding: 8px 4px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: 0.3s;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.sound-btn:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

.sound-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.volume-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

.volume-control input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.volume-value {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: right;
}

/* ============================================
   STATS GRID
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.stat-card {
    background: var(--card-bg);
    padding: 14px 10px;
    border-radius: var(--radius-sm);
    text-align: center;
    box-shadow: var(--shadow);
    transition: 0.3s;
}

.stat-card:hover {
    box-shadow: var(--shadow-hover);
}

.stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

/* ============================================
   STATS DETAIL
   ============================================ */
.stats-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.stat-detail-card {
    background: var(--card-bg);
    padding: 12px 10px;
    border-radius: var(--radius-sm);
    text-align: center;
    box-shadow: var(--shadow);
    transition: 0.3s;
}

.stat-detail-card.highlight {
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: #fff;
}

.stat-detail-card.highlight .stat-detail-label,
.stat-detail-card.highlight .stat-detail-sub {
    color: rgba(255, 255, 255, 0.8);
}

.stat-detail-card.highlight .stat-detail-value {
    color: #fff;
}

.stat-detail-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-detail-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 2px 0;
    letter-spacing: -0.5px;
}

.stat-detail-sub {
    font-size: 11px;
    font-weight: 600;
    color: var(--success);
}

/* ============================================
   CHART
   ============================================ */
.chart-section {
    background: var(--card-bg);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}

.chart-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.chart-icon {
    font-size: 18px;
    color: var(--text-muted);
}

.chart-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.chart-container {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 80px;
    gap: 4px;
}

.chart-bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.chart-bar {
    width: 100%;
    min-height: 4px;
    border-radius: 4px 4px 0 0;
    background: var(--primary);
    transition: height 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    opacity: 0.7;
}

.chart-bar.today {
    background: var(--purple);
    opacity: 1;
}

.chart-bar-label {
    font-size: 8px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 4px;
}

.chart-bar-value {
    font-size: 7px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.chart-empty {
    width: 100%;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    padding: 16px 0;
}

/* ============================================
   TOKEN INPUT
   ============================================ */
.token-section {
    background: var(--card-bg);
    padding: 12px 14px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}

.token-input-group {
    display: flex;
    gap: 8px;
}

.token-input-group input {
    flex: 1;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: 0.3s;
    background: var(--input-bg);
    color: var(--text-primary);
}

.token-input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.15);
}

.token-input-group input::placeholder {
    color: var(--text-muted);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 9px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 16px rgba(79, 110, 247, 0.30);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #d94a5a;
}

.btn-soft {
    background: var(--bg);
    color: var(--text-secondary);
}

.btn-soft:hover {
    background: var(--border);
}

.btn-soft.active {
    background: var(--primary);
    color: #fff;
}

.controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.controls .btn {
    padding: 8px;
    font-size: 11px;
    justify-content: center;
}

/* ============================================
   TRANSACTION LIST
   ============================================ */
.transaction-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.transaction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.transaction-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.transaction-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg);
    padding: 2px 10px;
    border-radius: 12px;
}

.transaction-list {
    max-height: 400px;
    overflow-y: auto;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    transition: 0.3s;
}

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-item:hover {
    background: var(--hover-bg);
}

.transaction-item .amount {
    font-size: 16px;
    font-weight: 700;
    color: var(--success);
}

.transaction-item .info {
    font-size: 12px;
    color: var(--text-secondary);
}

.transaction-item .time {
    font-size: 11px;
    color: var(--text-muted);
}

.transaction-item.new {
    background: rgba(79, 110, 247, 0.08);
    border-left: 3px solid var(--primary);
}

[data-theme="dark"] .transaction-item.new {
    background: rgba(79, 110, 247, 0.15);
}

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

.transaction-item {
    animation: slideIn 0.3s ease;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 30px 20px;
}

.empty-icon {
    font-size: 36px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.empty-state p {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

.empty-state span {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   QRIS OVERLAY
   ============================================ */
.qris-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.qris-overlay.active {
    display: flex;
}

.qris-modal {
    background: var(--card-bg);
    border-radius: 20px;
    max-width: 380px;
    width: 100%;
    padding: 20px;
    animation: slideUp 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.20);
    transition: background 0.3s;
}

@keyframes slideUp {
    from { transform: translateY(30px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.qris-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.qris-modal-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
}

.qris-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    transition: 0.3s;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.qris-close:hover {
    background: var(--danger);
    color: #fff;
}

.qris-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.qris-image {
    width: 100%;
    max-width: 280px;
    height: auto;
    border-radius: 12px;
    background: #fff;
    padding: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.qris-hint {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-align: center;
}

/* ============================================
   TOAST
   ============================================ */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.20);
    display: none;
    z-index: 999;
    font-size: 13px;
    font-weight: 500;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    display: block;
    animation: slideUp 0.3s ease;
}

[data-theme="dark"] .toast {
    background: var(--card-bg);
    color: var(--text-primary);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
    body {
        padding: 12px;
        padding-bottom: 60px;
    }
    
    .stats-grid {
        gap: 6px;
    }
    
    .stat-value {
        font-size: 18px;
    }
    
    .stats-detail-grid {
        gap: 6px;
    }
    
    .stat-detail-value {
        font-size: 16px;
    }
    
    .chart-container {
        height: 60px;
    }
    
    .controls {
        gap: 6px;
    }
    
    .controls .btn {
        font-size: 10px;
        padding: 6px 4px;
    }
    
    .header-left h1 {
        font-size: 15px;
    }
    
    .transaction-item {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .transaction-item .time {
        width: 100%;
        text-align: right;
    }
    
    .qris-modal {
        padding: 16px;
        margin: 10px;
    }
    
    .qris-image {
        max-width: 200px;
    }
    
    .qris-preview-image {
        max-width: 100px;
        max-height: 100px;
    }
    
    .qris-upload-box {
        padding: 14px 12px;
    }
    
    .qris-upload-btn {
        padding: 5px 12px;
        font-size: 10px;
    }
    
    .sound-upload-box {
        padding: 12px;
    }
    
    .sound-preview-container {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .sound-grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}