/* ============================================================
   Rupaya Khata — Customer Statement
   Premium Fintech-grade Design
   ============================================================ */

:root {
    --bg: #FAFAFA;
    --card-bg: #FFFFFF;
    --primary: #18181B; /* Zinc 900 */
    --primary-dark: #09090B;
    --accent: #2563EB; /* Professional Blue */
    --credit-color: #E11D48;
    --payment-color: #059669;
    --credit-bg: #FFF1F2;
    --payment-bg: #ECFDF5;
    --border: #E4E4E7; /* Zinc 200 */
    --text-primary: #18181B; /* Zinc 900 */
    --text-secondary: #71717A; /* Zinc 500 */
    --text-muted: #A1A1AA; /* Zinc 400 */
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100dvh;
}

.material-symbols-rounded {
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
}

/* ===================== SHELL ===================== */
.app-shell {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

/* ===================== APP BAR ===================== */
.app-bar {
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #FFFFFF;
    border-bottom: 1px solid #F0F0F5;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.lang-selector-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.globe-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--text-secondary);
    pointer-events: none;
}

.lang-select-minimal {
    padding: 6px 28px 6px 32px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
    transition: all 0.2s ease;
}

.lang-select-minimal:hover {
    background: #F4F4F5;
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: contain;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.brand-tagline {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 1px;
}

/* ===================== CONTENT ===================== */
.content-area {
    flex: 1;
    padding: 0 16px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.hidden { display: none !important; }

/* ===================== SHIMMER ===================== */
.state-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 16px;
}

.shimmer-card {
    border-radius: 16px;
    background: linear-gradient(110deg, #E5E7EB 8%, #F3F4F6 18%, #E5E7EB 33%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===================== ERROR ===================== */
.error-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    margin-top: 40px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.error-icon-md { font-size: 48px; color: var(--credit-color); display: block; margin-bottom: 16px; }
.error-card h2 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.error-card p { font-size: 14px; color: var(--text-muted); line-height: 1.5; }

/* ===================== SHOP BANNER ===================== */
.shop-banner {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
}

.shop-banner::before, .shop-banner::after {
    display: none; /* Remove amateur gradient overlays */
}

.shop-banner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 4px;
}

.shop-banner-content {
    flex: 1;
    min-width: 0;
}

.shop-banner-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    line-height: 1.2;
    margin-bottom: 0;
    word-break: break-word;
}

.shop-banner-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

.shop-banner-meta .material-symbols-rounded {
    font-size: 14px;
    color: var(--text-muted);
}

.shop-banner-meta span:not(.material-symbols-rounded) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shop-call-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #F4F4F5; /* Zinc 100 */
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex-shrink: 0;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.shop-call-btn:hover {
    background: #E4E4E7; /* Zinc 200 */
}

.shop-call-btn:active {
    transform: scale(0.95);
}

.shop-call-btn .material-symbols-rounded {
    font-size: 20px;
}

/* ===================== CUSTOMER HERO ===================== */
.customer-hero {
    padding: 16px 4px 8px 4px;
}

.hero-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.hero-greeting-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
}

.hero-customer-name {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.8px;
    line-height: 1.1;
}

/* ===================== ACCOUNT SUMMARY STATS ===================== */
.summary-stats {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border);
    overflow: hidden;
}

.stat-main {
    padding: 24px 20px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
}

.stat-main .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
}

.stat-main .stat-value {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -1px;
}

.stat-sub-group {
    display: flex;
    align-items: stretch;
}

.stat-item {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 12px;
}

.stat-divider {
    width: 1px;
    background: #E5E7EB;
    align-self: stretch;
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-dot {
    display: none;
}

.stat-dot.credit { }
.stat-dot.payment { }

.stat-value {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    word-break: break-word; /* Prevents overflow with large numbers */
}

.stat-value.credit { color: var(--credit-color); }
.stat-value.payment { color: var(--payment-color); }

.balance-due-item {
    /* Removed background for cleaner look */
}

.balance-due-item.owe { }
.balance-due-item.advance { }
.balance-due-item.settled { }

.stat-value.balance-due { color: #EA580C; }
.balance-due-item.owe .stat-value.balance-due { color: var(--credit-color); }
.balance-due-item.advance .stat-value.balance-due { color: var(--payment-color); }
.balance-due-item.settled .stat-value.balance-due { color: var(--text-secondary); }

/* ===================== TRANSACTION LIST ===================== */
.transactions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 32px;
}

/* Date Group Header */
.tx-date-header {
    padding: 16px 0 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tx-date-header::before,
.tx-date-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #E5E7EB;
}

.tx-date-header span {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    white-space: nowrap;
}

/* Transaction Tile */
.tx-tile {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.tx-tile:hover {
    border-color: #D4D4D8; /* Zinc 300 */
    box-shadow: 0 6px 16px rgba(0,0,0,0.06);
    transform: translateY(-2px) scale(1.01);
}

.tx-tile:active {
    background-color: #F4F4F5; /* Zinc 100 */
    transform: scale(0.98);
}

/* Circular icon */
.tx-icon-circle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tx-icon-circle .material-symbols-rounded { font-size: 20px; }

.tx-icon-circle.credit {
    background: var(--credit-bg);
    color: var(--credit-color);
}

.tx-icon-circle.payment {
    background: var(--payment-bg);
    color: var(--payment-color);
}

.tx-info {
    flex: 1;
    min-width: 0;
}

.tx-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.tx-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 400;
}

.tx-right {
    text-align: right;
    flex-shrink: 0;
}

.tx-amount {
    font-size: 15px;
    font-weight: 700;
}

.tx-amount.credit { color: var(--credit-color); }
.tx-amount.payment { color: var(--payment-color); }

.tx-due-badge {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    background: #F3F4F6;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ===================== EMPTY STATE ===================== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 56px;
    color: #D1D5DB;
    margin-bottom: 16px;
    display: block;
}

.state-illustration {
    width: 140px;
    height: 140px;
    object-fit: contain;
    margin: 0 auto 20px auto;
    display: block;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 13px;
    line-height: 1.5;
}


/* ===================== FOOTER ===================== */
.app-footer {
    text-align: center;
    padding: 24px 16px 32px;
    font-size: 13px;
    color: var(--text-muted);
}

.app-footer strong { color: var(--primary); font-weight: 600; }

/* ===================== ANIMATIONS ===================== */
.fade-up {
    opacity: 0;
    transform: translateY(12px);
    animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.delay-1 { animation-delay: 0.08s; }
.delay-2 { animation-delay: 0.16s; }

@keyframes fadeUp {
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 360px) {
    .stat-value { font-size: 16px; }
    .shop-banner-name { font-size: 18px; }
}

/* ===================== BOTTOM SHEET ===================== */
.bottom-sheet-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.bottom-sheet-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.bottom-sheet {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #FFFFFF;
    border-radius: 24px 24px 0 0;
    z-index: 1001;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
    padding: 16px 24px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
    display: flex; flex-direction: column;
}
.bottom-sheet.active {
    transform: translateY(0);
}
.sheet-handle {
    width: 36px; height: 4px;
    background: #D1D5DB;
    border-radius: 4px;
    margin: 0 auto 16px auto;
}
.sheet-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px;
}
.sheet-header h3 {
    margin: 0; font-size: 18px; font-weight: 700; color: var(--text-primary);
}
.icon-btn {
    background: #F3F4F6; border: none; cursor: pointer; color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    padding: 8px; border-radius: 50%;
    transition: background 0.15s ease;
}
.icon-btn:hover { background: #E5E7EB; }

.sheet-amount-box {
    text-align: center; margin-bottom: 24px; padding: 28px;
    border-radius: 16px; background: var(--bg);
}
.sheet-amount-box.credit { background: var(--credit-bg); }
.sheet-amount-box.payment { background: var(--payment-bg); }

.sheet-amount {
    font-size: 36px; font-weight: 800; margin-bottom: 8px;
    letter-spacing: -1px;
}
.sheet-amount-box.credit .sheet-amount { color: var(--credit-color); }
.sheet-amount-box.payment .sheet-amount { color: var(--payment-color); }

.sheet-type {
    display: inline-block; padding: 4px 14px; border-radius: 12px;
    font-size: 13px; font-weight: 600;
}
.sheet-amount-box.credit .sheet-type {
    background: rgba(220, 38, 38, 0.1); color: var(--credit-color);
}
.sheet-amount-box.payment .sheet-type {
    background: rgba(22, 163, 74, 0.1); color: var(--payment-color);
}

.sheet-row {
    display: flex; justify-content: space-between; padding: 16px 0;
    border-bottom: 1px solid #F0F0F5;
}
.sheet-row:last-child { border-bottom: none; }
.sheet-label {
    color: var(--text-secondary); font-size: 14px; font-weight: 500;
}
.sheet-value {
    color: var(--text-primary); font-size: 14px; font-weight: 600;
    text-align: right; max-width: 60%;
}

#sheet-notes-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}
.notes-text {
    font-weight: 400; word-break: break-word; line-height: 1.5; color: #4B5563;
    text-align: left; max-width: 100%; font-size: 13px;
}

/* ===================== DOWNLOAD BANNER ===================== */
.download-app-banner {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 50;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.04);
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 14px;
}

.banner-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: contain;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.banner-text {
    display: flex;
    flex-direction: column;
}

.banner-text h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
    letter-spacing: -0.3px;
}

.banner-text p {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.download-btn {
    background: var(--primary);
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 24px;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.download-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.download-btn:active {
    transform: scale(0.96);
}

/* ===================== DESKTOP POLISH ===================== */
@media (min-width: 600px) {
    body {
        background: #09090B; /* Dark premium background for desktop */
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 40px 0;
    }
    
    .app-shell {
        min-height: auto;
        height: 850px;
        max-height: 90vh;
        width: 100%;
        max-width: 440px;
        border-radius: 36px;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 10px #18181B, 0 0 0 12px #27272A;
        overflow-y: auto;
        position: relative;
    }
    
    .app-shell::-webkit-scrollbar {
        width: 0px;
        background: transparent;
    }
    
    .app-bar {
        border-radius: 36px 36px 0 0;
    }
    
    .bottom-sheet {
        position: absolute;
        border-radius: 24px 24px 36px 36px;
    }
    
    .bottom-sheet-overlay {
        position: absolute;
        border-radius: 36px;
    }
}
