/* ============================================
   File: css/style.css
   Purpose: Styling matching the original
   Digital Ledger prototype's design language
   ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8fafc;
    color: #1f2937;
    -webkit-tap-highlight-color: transparent;
}

.hidden {
    display: none !important;
}

.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: #f59e0b;
    color: #fff;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 12px;
}

.screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ============================================
   LOGIN SCREEN
   ============================================ */

#login-screen {
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #10b981, #2196F3);
    padding: 20px;
}

.login-box {
    background: #ffffff;
    border-radius: 24px;
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.login-logo { width: 56px; height: 56px; margin: 0 auto 12px; color: #10b981; }
.login-logo svg { width: 100%; height: 100%; }
.login-box h1 { font-size: 21px; color: #111827; margin-bottom: 4px; }
.login-subtitle { color: #6b7280; font-size: 14px; margin-bottom: 24px; }

.name-select { display: flex; gap: 10px; }

.name-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid #e5e7eb;
    background: #fff;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    color: #6b7280;
    cursor: pointer;
}

.name-btn.selected {
    border-color: #10b981;
    background: #d1fae5;
    color: #047857;
}

/* ============================================
   FORM ELEMENTS (shared)
   ============================================ */

.form-group { margin-bottom: 18px; text-align: left; position: relative; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    font-size: 16px;
    outline: none;
    background: #fff;
}

.form-group input:focus { border-color: #10b981; }

.hint-text { font-size: 12px; color: #9ca3af; margin-top: 6px; }

.btn {
    padding: 15px 20px;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; }
.btn-primary { background: #10b981; color: #fff; box-shadow: 0 8px 20px rgba(16,185,129,0.25); }
.btn-full { width: 100%; }

.error-text {
    color: #ef4444;
    font-size: 13px;
    margin-top: 6px;
    min-height: 16px;
    text-align: center;
}

/* ============================================
   DASHBOARD SCREEN
   ============================================ */

.scroll-area { flex: 1; overflow-y: auto; padding-bottom: 100px; }

.dash-greeting { font-size: 12px; color: #6b7280; }
#dash-user-name { font-size: 18px; font-weight: 800; color: #111827; }

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
    position: sticky;
    top: 0;
    z-index: 30;
}

.icon-btn-light svg, .icon-btn-dark svg, .icon-btn svg { width: 19px; height: 19px; }

.top-header-left { display: flex; align-items: center; gap: 12px; }
.top-header-logo { width: 30px; height: 30px; color: #10b981; display: flex; align-items: center; justify-content: center; }
.top-header-logo svg { width: 100%; height: 100%; }
.top-header-actions { display: flex; gap: 8px; }

.icon-btn-light {
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #374151;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn-dark {
    background: #f3f4f6;
    border: none;
    color: #111827;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hero Balance Card */
.hero-card {
    margin: 16px 16px 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 28px;
    padding: 22px;
    color: #fff;
    box-shadow: 0 15px 30px rgba(16, 185, 129, 0.3);
}

.hero-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.hero-label { font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; color: #d1fae5; margin-bottom: 4px; }
.hero-amount { font-size: 34px; font-weight: 900; }
.hero-icon { background: rgba(255,255,255,0.2); padding: 10px; border-radius: 16px; width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; }
.hero-icon svg { width: 100%; height: 100%; }

.hero-bottom {
    display: flex;
    justify-content: space-between;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.25);
}

.hero-sublabel { font-size: 11px; color: #d1fae5; margin-bottom: 3px; }
.hero-subvalue { font-size: 13px; font-weight: 700; }

.section-row { display: flex; justify-content: space-between; align-items: center; padding: 0 16px; margin-bottom: 12px; }
.section-row h3 { font-size: 19px; font-weight: 800; color: #111827; }

.filter-row {
    display: flex;
    gap: 8px;
    padding: 0 16px;
    margin-bottom: 16px;
    overflow-x: auto;
}

.filter-btn {
    padding: 10px 18px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
}

.filter-btn.active { background: #111827; color: #fff; border-color: #111827; }

/* Customer List */
.customers-list { display: flex; flex-direction: column; gap: 10px; padding: 0 16px; }

.customer-card {
    background: #fff;
    border-radius: 20px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid #f3f4f6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    cursor: pointer;
}

.customer-card:active { transform: scale(0.98); }

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}

.customer-card-info { flex: 1; min-width: 0; }
.customer-card-name { font-size: 16px; font-weight: 700; color: #111827; }
.customer-card-sub { font-size: 12px; color: #6b7280; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.customer-card-balance { text-align: right; flex-shrink: 0; }
.customer-card-balance .amount { font-size: 15px; font-weight: 800; }
.customer-card-balance .amount.owes { color: #ef4444; }
.customer-card-balance .amount.advance { color: #10b981; }
.customer-card-balance .tag { font-size: 10px; color: #9ca3af; text-transform: uppercase; }

.empty-message { text-align: center; color: #9ca3af; font-size: 14px; padding: 40px 20px; }

.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #111827;
    color: #fff;
    font-size: 30px;
    border: none;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 20;
}

.fab:active { transform: scale(0.95); }

/* ============================================
   CUSTOMER DETAIL SCREEN
   ============================================ */

.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
}

.detail-header-info { flex: 1; min-width: 0; }
.detail-header-info h2 { font-size: 17px; font-weight: 800; color: #111827; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-phone { font-size: 12px; color: #6b7280; margin-top: 2px; }

.detail-balance-card {
    margin: 14px 16px;
    padding: 18px;
    border-radius: 20px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-balance-card.owes { background: #fef2f2; border-color: #fecaca; }
.detail-balance-card.advance { background: #ecfdf5; border-color: #a7f3d0; }

.detail-balance-label { font-size: 11px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.detail-balance-amount { font-size: 26px; font-weight: 900; color: #111827; }
.detail-balance-amount.owes { color: #ef4444; }
.detail-balance-amount.advance { color: #10b981; }

.balance-tag {
    font-size: 11px;
    font-weight: 800;
    padding: 6px 12px;
    border-radius: 999px;
    text-transform: uppercase;
    background: #e5e7eb;
    color: #4b5563;
}

.balance-tag.owes { background: #fecaca; color: #991b1b; }
.balance-tag.advance { background: #a7f3d0; color: #065f46; }

.detail-entries-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 16px 100px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.date-divider { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.date-divider .line { flex: 1; height: 1px; background: #e5e7eb; }
.date-divider span { font-size: 11px; font-weight: 700; color: #9ca3af; background: #f3f4f6; padding: 4px 12px; border-radius: 999px; text-transform: uppercase; }

.date-group-card { background: #fff; border-radius: 18px; border: 1px solid #f3f4f6; overflow: hidden; }

.entry-row {
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f9fafb;
}

.entry-row:first-child { border-top: none; }

.entry-row-left { display: flex; align-items: center; gap: 12px; }

.entry-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.entry-icon.credit { background: #fee2e2; color: #ef4444; }
.entry-icon.debit { background: #d1fae5; color: #10b981; }
.entry-icon svg { width: 17px; height: 17px; }

.entry-amount-text { font-size: 15px; font-weight: 800; color: #111827; }

.pending-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    color: #b45309;
    background: #fef3c7;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    vertical-align: middle;
    margin-left: 4px;
}
.entry-meta-text { font-size: 11px; color: #6b7280; margin-top: 2px; }

.entry-running-balance { font-size: 12px; font-weight: 700; color: #9ca3af; text-align: right; }

.entry-row-right { display: flex; align-items: center; gap: 8px; }

.entry-menu-btn {
    background: transparent;
    border: none;
    color: #9ca3af;
    padding: 6px;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.entry-menu-btn svg { width: 18px; height: 18px; }

.entry-menu-btn:active { background: #f3f4f6; }

.action-sheet { padding-bottom: max(22px, env(safe-area-inset-bottom)); }

.action-sheet-btn {
    width: 100%;
    text-align: left;
    padding: 16px 14px;
    border: none;
    background: transparent;
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
}

.action-icon { width: 20px; height: 20px; flex-shrink: 0; }

.action-sheet-btn:last-child { border-bottom: none; }
.action-sheet-danger { color: #ef4444; }
.action-sheet-whatsapp { color: #25a24a; }
.action-sheet-sms { color: #3b82f6; }
.action-sheet-cancel { color: #6b7280; text-align: center; justify-content: center; margin-top: 6px; }

.detail-actions {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    background: #fff;
    border-top: 1px solid #f3f4f6;
    position: sticky;
    bottom: 0;
}

.btn-half {
    flex: 1;
    padding: 15px;
    border-radius: 16px;
    font-weight: 800;
    font-size: 14px;
    border: none;
    cursor: pointer;
}

.btn-received { background: #d1fae5; color: #047857; border: 1px solid #a7f3d0; }
.btn-gave { background: #ef4444; color: #fff; box-shadow: 0 8px 20px rgba(239,68,68,0.25); }

/* ============================================
   ADD CUSTOMER SCREEN / SIMPLE SCREENS
   ============================================ */

.simple-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
}

.simple-header h2 { font-size: 17px; font-weight: 800; color: #111827; }

.simple-body { flex: 1; padding: 20px; background: #f8fafc; }

.card-box {
    background: #fff;
    padding: 20px;
    border-radius: 24px;
    border: 1px solid #f3f4f6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.simple-footer { padding: 16px; background: #fff; border-top: 1px solid #f3f4f6; }

/* ============================================
   ADD ENTRY MODAL
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 50;
}

.modal-box {
    background: #fff;
    width: 100%;
    max-width: 480px;
    border-radius: 24px 24px 0 0;
    padding: 22px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-header h3 { font-size: 18px; font-weight: 800; }

.icon-btn {
    background: #f3f4f6;
    border: none;
    color: #374151;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.type-toggle-pill {
    display: flex;
    background: #f3f4f6;
    padding: 4px;
    border-radius: 999px;
    margin-bottom: 22px;
}

.pill-btn {
    flex: 1;
    padding: 10px;
    text-align: center;
    border-radius: 999px;
    font-weight: 800;
    font-size: 13px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
}

.pill-btn.pill-gave.active { background: #fff; color: #ef4444; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.pill-btn.pill-received.active { background: #fff; color: #10b981; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }

.amount-input-wrap { position: relative; margin-bottom: 18px; }

.amount-currency {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    font-size: 24px;
    font-weight: 800;
    color: #9ca3af;
}

.amount-input-wrap input {
    width: 100%;
    padding: 16px 16px 16px 46px;
    border: none;
    border-bottom: 2px solid #e5e7eb;
    background: #f9fafb;
    font-size: 30px;
    font-weight: 800;
    outline: none;
    border-radius: 12px 12px 0 0;
}

.amount-input-wrap input:focus { border-color: #10b981; }

.save-entry-btn { background: #ef4444; color: #fff; margin-top: 10px; }
.save-entry-btn.type-debit { background: #10b981; }

/* ============================================
   TOAST
   ============================================ */

.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: #111827;
    color: #fff;
    padding: 12px 22px;
    border-radius: 999px;
    font-size: 14px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    max-width: 90%;
    text-align: center;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (min-width: 600px) {
    .screen { max-width: 480px; margin: 0 auto; }
}
