/* Orventa Mobile Dashboard PWA - Mobile-First CSS */
:root {
    --bg: #1B1A17;
    --card-bg: #242320;
    --input-bg: #2a2925;
    --border: #3a3835;
    --accent: #D97757;
    --accent-hover: #e08a6a;
    --text: #e8e4de;
    --text-secondary: #9e9a93;
    --text-muted: #6b6762;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --info: #3b82f6;
    --tab-height: 60px;
    --top-height: 50px;
}
body.light {
    --bg: #f5f3ef;
    --card-bg: #ffffff;
    --input-bg: #f0ede8;
    --border: #ddd9d2;
    --text: #1B1A17;
    --text-secondary: #6b6762;
    --text-muted: #9e9a93;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); overflow-x: hidden; -webkit-font-smoothing: antialiased; }
html { overflow-x: hidden; }

/* ===== TOP BAR ===== */
.top-bar { position: fixed; top: 0; left: 0; right: 0; height: var(--top-height); background: var(--card-bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; z-index: 100; }
.company-name { font-weight: 700; font-size: 1.05em; }
.sync-badge { font-size: 0.7em; background: var(--input-bg); padding: 4px 8px; border-radius: 12px; color: var(--text-secondary); }

/* ===== TAB BAR ===== */
.tab-bar { position: fixed; bottom: 0; left: 0; right: 0; height: var(--tab-height); background: var(--card-bg); border-top: 1px solid var(--border); display: flex; z-index: 100; padding-bottom: env(safe-area-inset-bottom, 0); }
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: none; border: none; color: var(--text-muted); cursor: pointer; font-family: inherit; transition: color 0.2s; -webkit-tap-highlight-color: transparent; }
.tab-btn.active { color: var(--accent); }
.tab-icon { font-size: 1.3em; }
.tab-label { font-size: 0.65em; font-weight: 500; }

/* ===== TAB CONTENT ===== */
.tab-content { padding: calc(var(--top-height) + 12px) 12px calc(var(--tab-height) + 12px); min-height: 100vh; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ===== STATS GRID ===== */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--card-bg); border-radius: 12px; padding: 14px; border: 1px solid var(--border); }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.warn .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-value { font-size: 1.3em; font-weight: 700; }
.stat-label { font-size: 0.72em; color: var(--text-secondary); margin-top: 2px; }
.loading-pulse { animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Pipeline */
.stat-card.pipeline { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
.pipe-item { font-size: 0.75em; padding: 3px 8px; border-radius: 6px; text-transform: capitalize; }
.pipe-item.draft { background: rgba(113,113,122,0.15); color: #a1a1aa; }
.pipe-item.picking { background: rgba(59,130,246,0.15); color: #60a5fa; }
.pipe-item.ready { background: rgba(34,197,94,0.15); color: #22c55e; }
.pipe-item.invoiced { background: rgba(168,85,247,0.15); color: #a855f7; }
.pipe-item.posted { background: rgba(20,184,166,0.15); color: #14b8a6; }

/* ===== SECTION HEADER ===== */
.section-header { font-size: 0.8em; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin: 16px 0 8px; padding: 0 4px; }

/* ===== SEARCH BAR ===== */
.search-bar { margin-bottom: 10px; }
.search-bar input { width: 100%; padding: 10px 14px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-size: 0.95em; font-family: inherit; outline: none; -webkit-appearance: none; }
.search-bar input:focus { border-color: var(--accent); }
.search-bar input::placeholder { color: var(--text-muted); }

/* ===== FILTER PILLS ===== */
.filter-pills { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.filter-pills::-webkit-scrollbar { display: none; }
.pill { padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text-secondary); font-size: 0.8em; font-family: inherit; cursor: pointer; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== LIST ROWS ===== */
.list-container { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 0.15s; }
.list-row:active { background: var(--input-bg); }
.list-row-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.list-row-title { font-weight: 600; font-size: 0.9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row-sub { font-size: 0.75em; color: var(--text-secondary); margin-top: 2px; }
.list-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin-left: 12px; flex-shrink: 0; }
.list-row-amount { font-weight: 600; font-size: 0.9em; }
.list-empty { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 0.9em; }

/* ===== STATUS BADGES ===== */
.status-badge { font-size: 0.65em; padding: 2px 8px; border-radius: 10px; text-transform: capitalize; font-weight: 500; }
.st-draft { background: rgba(113,113,122,0.15); color: #a1a1aa; }
.st-picking { background: rgba(59,130,246,0.15); color: #60a5fa; }
.st-ready { background: rgba(34,197,94,0.15); color: #22c55e; }
.st-invoiced { background: rgba(168,85,247,0.15); color: #a855f7; }
.st-posted { background: rgba(20,184,166,0.15); color: #14b8a6; }
.st-voided { background: rgba(239,68,68,0.15); color: #ef4444; }

/* ===== LOAD MORE ===== */
.load-more { text-align: center; padding: 10px; }
.load-more button { padding: 10px 24px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 10px; color: var(--accent); font-family: inherit; font-size: 0.9em; cursor: pointer; }

/* ===== SLIDE PANEL ===== */
.slide-panel { position: fixed; top: 0; right: -100%; width: 100%; height: 100%; background: var(--bg); z-index: 200; transition: right 0.25s ease; overflow-y: auto; }
.slide-panel.open { right: 0; }
.slide-panel-header { position: sticky; top: 0; background: var(--card-bg); border-bottom: 1px solid var(--border); padding: 12px 16px; display: flex; align-items: center; gap: 12px; z-index: 1; }
.slide-back { background: none; border: none; color: var(--accent); font-size: 1.3em; cursor: pointer; padding: 4px; font-family: inherit; }
.slide-title { font-weight: 600; font-size: 1em; }
.slide-panel-body { padding: 16px; padding-bottom: 40px; }

/* ===== DETAIL SECTIONS ===== */
.detail-section { background: var(--card-bg); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; margin-bottom: 12px; }
.detail-section h3 { padding: 14px 14px 0; font-size: 1em; }
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 0.88em; }
.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: var(--text-secondary); }
.detail-row.total { font-size: 1em; }
.detail-row.total strong { color: var(--accent); font-size: 1.1em; }
.detail-row.warn strong { color: var(--warning); }
.detail-section.totals { margin-top: 16px; }

/* Items table in invoice detail */
.items-table { margin-bottom: 4px; }
.item-row { display: flex; justify-content: space-between; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--card-bg); }
.item-row:last-child { border-bottom: none; }
.item-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.item-name { font-size: 0.85em; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-code { font-size: 0.7em; color: var(--text-muted); }
.item-nums { display: flex; flex-direction: column; align-items: flex-end; font-size: 0.82em; margin-left: 10px; }

/* ===== MORE MENU ===== */
.more-menu { display: flex; flex-direction: column; gap: 2px; margin-bottom: 20px; }
.more-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-size: 0.95em; font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.more-item:active { background: var(--input-bg); }
.more-item.danger { color: var(--danger); }
.more-icon { font-size: 1.2em; width: 28px; text-align: center; }
.more-arrow { margin-left: auto; color: var(--text-muted); font-size: 1.3em; }
.more-divider { height: 1px; background: var(--border); margin: 8px 0; }

/* User info */
.user-info-card { margin-top: 8px; }

/* ===== TOAST ===== */
.toast { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); padding: 10px 20px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; font-size: 0.85em; opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 300; }
.toast.show { opacity: 1; }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--success); color: var(--success); }

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
    .tab-content { max-width: 600px; margin: 0 auto; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
    .tab-content { max-width: 800px; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .slide-panel { max-width: 480px; box-shadow: -4px 0 20px rgba(0,0,0,0.3); }
}
