/* ===== GrowAcc Mobile CSS ===== */
:root {
    --primary: #0d7c66;
    --primary-dark: #0a5e4e;
    --primary-light: #e8f5f1;
    --bg: #f5f5f5;
    --card: #ffffff;
    --text: #333333;
    --text-light: #888888;
    --border: #e8e8e8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --blue: #1e88e5;
    --purple: #7b1fa2;
    --orange: #e65100;
    --teal: #00897b;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --nav-height: 60px;
    --top-height: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Kanit', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

/* ===== SCREENS ===== */
.screen { display: none; height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ===== LOGIN ===== */
#login-screen {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    justify-content: center; align-items: center;
    padding: 24px;
}
.login-container { width: 100%; max-width: 360px; }
.login-logo { text-align: center; color: white; margin-bottom: 36px; }
.login-logo i { font-size: 48px; margin-bottom: 12px; }
.login-logo h1 { font-size: 28px; font-weight: 600; letter-spacing: 1px; }
.login-logo p { font-size: 13px; opacity: 0.85; margin-top: 4px; }

.input-group {
    display: flex; align-items: center; gap: 12px;
    background: rgba(255,255,255,0.15); border-radius: 12px;
    padding: 0 16px; margin-bottom: 14px;
    border: 1px solid rgba(255,255,255,0.2);
    transition: background 0.2s;
}
.input-group:focus-within { background: rgba(255,255,255,0.25); border-color: rgba(255,255,255,0.4); }
.input-group i { color: rgba(255,255,255,0.7); font-size: 16px; width: 20px; text-align: center; }
.input-group input {
    flex: 1; background: none; border: none; outline: none;
    color: white; font-family: inherit; font-size: 15px;
    padding: 14px 0;
}
.input-group input::placeholder { color: rgba(255,255,255,0.5); }

.login-footer { text-align: center; margin-top: 24px; }
.login-footer a { color: rgba(255,255,255,0.7); font-size: 13px; text-decoration: none; }
.login-footer a:hover { color: white; }

/* ===== BUTTONS ===== */
.btn-primary {
    background: white; color: var(--primary); border: none;
    padding: 14px 24px; border-radius: 12px;
    font-family: inherit; font-size: 15px; font-weight: 500;
    cursor: pointer; display: flex; align-items: center;
    justify-content: center; gap: 8px;
    transition: transform 0.1s, opacity 0.2s;
    width: auto;
}
.btn-primary:active { transform: scale(0.97); }
.btn-full { width: 100%; }

.btn-sm {
    padding: 8px 16px; border-radius: 8px;
    font-family: inherit; font-size: 13px; font-weight: 500;
    border: none; cursor: pointer; display: inline-flex;
    align-items: center; gap: 6px;
}
.btn-green { background: var(--success); color: white; }
.btn-blue { background: var(--blue); color: white; }
.btn-red { background: var(--danger); color: white; }
.btn-outline-sm { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: none; border: none; color: var(--primary); font-family: inherit; font-size: 14px; font-weight: 500; cursor: pointer; padding: 8px 12px; }

.icon-btn {
    background: none; border: none; color: inherit;
    width: 40px; height: 40px; display: flex;
    align-items: center; justify-content: center;
    border-radius: 50%; cursor: pointer; font-size: 18px;
}
.icon-btn:active { background: rgba(0,0,0,0.05); }

/* ===== TOP BAR ===== */
.top-bar {
    height: var(--top-height);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
    z-index: 10;
}
.top-bar h2 { font-size: 17px; font-weight: 500; }
.top-right { display: flex; align-items: center; gap: 4px; }
.user-badge { font-size: 12px; opacity: 0.85; }
.top-bar .icon-btn { color: rgba(255,255,255,0.85); }

/* ===== CONTENT ===== */
.content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    padding-bottom: calc(var(--nav-height) + 16px);
    -webkit-overflow-scrolling: touch;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    height: var(--nav-height);
    background: white;
    display: flex;
    align-items: stretch;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px; background: none; border: none;
    color: #aaa; font-family: inherit; font-size: 10px;
    cursor: pointer; transition: color 0.2s; padding: 4px 0;
}
.nav-item i { font-size: 20px; }
.nav-item.active { color: var(--primary); }
.nav-item.nav-create {
    position: relative;
}
.nav-item.nav-create i {
    background: var(--primary);
    color: white;
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    margin-top: -18px;
    box-shadow: 0 2px 10px rgba(13,124,102,0.35);
}
.nav-item.nav-create span { margin-top: 2px; }
.nav-item.nav-create.active i { background: var(--primary-dark); }

/* ===== CARDS ===== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
}

/* ===== DASHBOARD ===== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    text-align: center;
}
.stat-card .stat-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 8px; font-size: 18px;
}
.stat-card .stat-value { font-size: 20px; font-weight: 600; color: var(--text); }
.stat-card .stat-label { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.orange { background: #fef3c7; color: #d97706; }

.section-title {
    font-size: 15px; font-weight: 500; margin: 20px 0 10px;
    display: flex; align-items: center; justify-content: space-between;
}
.section-title .see-all { font-size: 13px; color: var(--primary); font-weight: 400; cursor: pointer; }

/* ===== DOCUMENT LIST ===== */
.doc-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.1s;
    border-left: 4px solid var(--primary);
}
.doc-card:active { transform: scale(0.98); }
.doc-card .doc-icon {
    width: 42px; height: 42px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: white; flex-shrink: 0;
}
.doc-card .doc-info { flex: 1; min-width: 0; }
.doc-card .doc-number { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card .doc-customer { font-size: 12px; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card .doc-right { text-align: right; flex-shrink: 0; }
.doc-card .doc-amount { font-weight: 600; font-size: 14px; }
.doc-card .doc-date { font-size: 11px; color: var(--text-light); }

.doc-badge {
    display: inline-block; padding: 2px 8px;
    border-radius: 20px; font-size: 10px; font-weight: 500;
}
.badge-draft { background: #f3f4f6; color: #6b7280; }
.badge-sent { background: #dbeafe; color: #2563eb; }
.badge-paid { background: #dcfce7; color: #16a34a; }
.badge-partial { background: #fef3c7; color: #d97706; }
.badge-overdue { background: #fee2e2; color: #dc2626; }
.badge-cancelled { background: #fce7f3; color: #be185d; }

/* ===== FILTER TABS ===== */
.filter-tabs {
    display: flex; gap: 6px; overflow-x: auto;
    padding-bottom: 10px; margin-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
    padding: 7px 14px; border-radius: 20px;
    background: white; border: 1px solid var(--border);
    font-family: inherit; font-size: 12px; color: var(--text-light);
    cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.filter-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== SEARCH ===== */
.search-bar {
    display: flex; align-items: center; gap: 10px;
    background: white; border-radius: 10px;
    padding: 0 14px; margin-bottom: 12px;
    border: 1px solid var(--border);
}
.search-bar i { color: #bbb; font-size: 16px; }
.search-bar input {
    flex: 1; border: none; outline: none; background: none;
    font-family: inherit; font-size: 14px; padding: 12px 0;
}

/* ===== CREATE PAGE ===== */
.create-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.create-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 14px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.1s;
    border-top: 3px solid var(--primary);
}
.create-card:active { transform: scale(0.96); }
.create-card i { font-size: 28px; margin-bottom: 8px; display: block; }
.create-card span { font-size: 13px; font-weight: 500; }

/* ===== CUSTOMER LIST ===== */
.cust-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}
.cust-card:active { transform: scale(0.98); }
.cust-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--primary-light); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 600; flex-shrink: 0;
}
.cust-card .cust-info { flex: 1; min-width: 0; }
.cust-card .cust-name { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-card .cust-detail { font-size: 12px; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== MORE PAGE ===== */
.menu-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.menu-item {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer; font-size: 14px;
    transition: background 0.15s;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: #f9f9f9; }
.menu-item i { width: 24px; text-align: center; color: var(--primary); font-size: 18px; }
.menu-item .menu-arrow { margin-left: auto; color: #ccc; font-size: 14px; }

/* ===== MODAL ===== */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    animation: fadeIn 0.2s;
}
.modal-overlay.show { display: flex; flex-direction: column; justify-content: flex-end; }
.modal-sheet {
    background: white;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.25s ease-out;
}
.modal-header {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal-header h3 { flex: 1; font-size: 16px; font-weight: 500; text-align: center; }
.modal-body {
    flex: 1; overflow-y: auto; padding: 16px;
    -webkit-overflow-scrolling: touch;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ===== FORM ===== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: #555; margin-bottom: 5px; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 12px 14px;
    border: 1px solid var(--border); border-radius: 10px;
    font-family: inherit; font-size: 14px;
    background: white; color: var(--text);
    outline: none; transition: border-color 0.2s;
    -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); }
.form-textarea { min-height: 80px; resize: vertical; }
.form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

/* ===== LINE ITEMS ===== */
.line-item {
    background: #fafafa; border: 1px solid var(--border);
    border-radius: 10px; padding: 12px; margin-bottom: 10px;
    position: relative;
}
.line-item .remove-line {
    position: absolute; top: 8px; right: 8px;
    width: 28px; height: 28px; border-radius: 50%;
    background: #fee2e2; color: var(--danger); border: none;
    font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

.summary-box {
    background: var(--primary-light); border-radius: 10px;
    padding: 14px; margin-top: 12px;
}
.sum-line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; color: #555; }
.sum-line.total { font-size: 16px; font-weight: 600; color: var(--primary); border-top: 2px solid var(--primary); padding-top: 8px; margin-top: 6px; }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: calc(var(--nav-height) + 20px);
    left: 50%; transform: translateX(-50%) translateY(100px);
    background: #333; color: white;
    padding: 12px 24px; border-radius: 10px;
    font-size: 13px; z-index: 200;
    transition: transform 0.3s ease;
    white-space: nowrap;
    max-width: 90%;
    text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ===== DETAIL VIEW ===== */
.detail-header { margin-bottom: 16px; }
.detail-header .doc-type-badge {
    display: inline-block; padding: 4px 12px;
    border-radius: 20px; color: white; font-size: 12px;
    font-weight: 500; margin-bottom: 8px;
}
.detail-header h2 { font-size: 18px; font-weight: 600; }
.detail-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.detail-row .label { color: var(--text-light); }
.detail-row .value { font-weight: 500; text-align: right; max-width: 60%; word-break: break-word; }

.detail-items { margin-top: 16px; }
.detail-item {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 10px 0; border-bottom: 1px solid #f0f0f0;
}
.detail-item .item-desc { flex: 1; font-size: 13px; }
.detail-item .item-qty { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.detail-item .item-total { font-weight: 500; font-size: 14px; text-align: right; flex-shrink: 0; margin-left: 12px; }

.detail-actions {
    display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap;
}
.detail-actions .btn-sm { flex: 1; justify-content: center; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center; padding: 40px 20px; color: var(--text-light);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* ===== LOADING ===== */
.loading { text-align: center; padding: 40px; color: var(--text-light); }
.loading i { font-size: 24px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== EXPENSE CARD ===== */
.expense-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}
.expense-icon {
    width: 42px; height: 42px; border-radius: 10px;
    background: #fee2e2; color: var(--danger);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}
.expense-card .exp-info { flex: 1; min-width: 0; }
.expense-card .exp-desc { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expense-card .exp-cat { font-size: 12px; color: var(--text-light); }
.expense-card .exp-amount { font-weight: 600; font-size: 14px; color: var(--danger); flex-shrink: 0; }

/* ===== PRODUCT CARD ===== */
.product-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.product-icon {
    width: 42px; height: 42px; border-radius: 10px;
    background: #ede9fe; color: #7c3aed;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}
.product-card .prod-info { flex: 1; min-width: 0; }
.product-card .prod-name { font-weight: 500; font-size: 14px; }
.product-card .prod-code { font-size: 12px; color: var(--text-light); }
.product-card .prod-price { font-weight: 600; font-size: 14px; color: var(--primary); flex-shrink: 0; }

/* ===== PULL TO REFRESH HINT ===== */
.refresh-hint {
    text-align: center; padding: 8px; font-size: 12px; color: var(--text-light);
    display: none;
}
