/* ===== Page specific styles: Home, POS, Account, Customers, Invoice ===== */

/* ---------- Home (dashboard) ---------- */
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px; }
.dash-grid .panel + .panel { margin-top: 0; }

.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.chart-legend span::before {
    content: ""; display: inline-block;
    width: 10px; height: 10px; border-radius: 3px;
    margin-right: 6px; vertical-align: middle;
}
.chart-legend .legend-sales::before { background: var(--brand-primary); }
.chart-legend .legend-profit::before { background: var(--success); }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 230px; overflow-x: auto; padding-bottom: 4px; }
.chart-col { flex: 1; min-width: 22px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.chart-bar { width: 42%; max-width: 18px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-sales { background: var(--brand-primary); }
.bar-profit { background: var(--success); }
.chart-label { font-size: 11px; color: var(--muted); margin-top: 6px; white-space: nowrap; }

.top-list { list-style: none; }
.top-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.top-item:last-child { border-bottom: none; }
.top-row { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.top-track { background: var(--bg); border-radius: 4px; height: 6px; margin-top: 6px; overflow: hidden; }
.top-fill { background: var(--brand-primary); height: 100%; border-radius: 4px; }

.attention-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.attention-tile {
    display: flex; align-items: center; gap: 14px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.attention-tile:hover { border-color: var(--brand-primary); }
.attention-icon {
    width: 44px; height: 44px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    background: var(--warning-light);
}
.attention-tile.danger .attention-icon { background: var(--danger-light); }
.attention-tile.info .attention-icon { background: var(--brand-primary-light); }
.attention-count { font-size: 20px; font-weight: 700; }
.attention-text { color: var(--muted); font-size: 13px; }

/* ---------- POS ---------- */
.content-pos { overflow: hidden; padding: 14px; }
.pos-layout { height: 100%; display: grid; grid-template-columns: 130px 1fr 350px; gap: 14px; }
.pos-layout .panel { box-shadow: none; }

.categories {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 10px;
    overflow-y: auto;
}
.category-btn {
    width: 100%;
    padding: 12px 6px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    font-family: inherit;
}
.category-btn .icon { display: block; font-size: 24px; margin-bottom: 4px; }
.category-btn.active { background: var(--brand-primary); color: var(--white); border-color: var(--brand-primary); }

.products { display: flex; flex-direction: column; min-height: 0; }
.products .panel-tools input { width: 260px; }
.product-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    align-content: start;
}
.product-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: box-shadow 0.15s, transform 0.15s;
    position: relative;
}
.product-card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08); transform: translateY(-2px); }
.product-card .icon { font-size: 36px; }
.product-card .name { font-size: 14px; font-weight: 600; margin: 8px 0 4px; }
.product-card .price { color: var(--brand-primary); font-weight: 700; }
.product-card .stock { font-size: 12px; color: var(--muted); }
.product-card.disabled { opacity: 0.55; cursor: not-allowed; }
.product-card.disabled:hover { box-shadow: none; transform: none; }
.product-card .tag { position: absolute; top: 6px; right: 6px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.empty { color: var(--muted); padding: 20px; text-align: center; grid-column: 1 / -1; }

.cart { display: flex; flex-direction: column; min-height: 0; }
.cart .section-title { display: flex; justify-content: space-between; margin-bottom: 12px; }
.order-no { color: var(--muted); font-weight: 500; font-size: 13px; }
.customer-row { display: flex; gap: 8px; margin-bottom: 10px; }
.customer-row .btn { padding: 8px 12px; white-space: nowrap; }
.cart-items { flex: 1; overflow-y: auto; border-top: 1px solid var(--border); }
.cart-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.cart-item .title { font-size: 14px; font-weight: 600; }
.cart-item .unit { font-size: 12px; color: var(--muted); }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button {
    width: 26px; height: 26px;
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
}
.remove-btn { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 18px; }
.cart-summary { padding: 12px 0; }
.cart-summary .row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 14px; }
.cart-summary .row input { width: 90px; text-align: right; padding: 6px 8px; }
.cart-summary .total { font-size: 18px; font-weight: 700; border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 10px; }
.cart-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }

.pay-total-box, .pay-due-box {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--brand-primary-light);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
}
.pay-total-box strong, .pay-due-box strong { font-size: 20px; color: var(--brand-primary); }
.pay-due-box { background: var(--danger-light); }
.pay-due-box strong { color: var(--danger); }
.pay-customer { display: flex; flex-direction: column; margin-bottom: 12px; }
.pay-customer span { color: var(--muted); font-size: 13px; }
.pay-method { margin-top: 14px; }
.pay-remaining, .pay-balance { margin-top: 14px; font-size: 14px; }
.quick-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.hint-text { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- Account ---------- */
.account-hero {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
}
.hero-cover { height: 120px; background: linear-gradient(120deg, var(--brand-sidebar), var(--brand-primary)); }
.hero-body { display: flex; align-items: flex-end; gap: 20px; padding: 0 24px 22px; flex-wrap: wrap; margin-top: -44px; }
.hero-logo {
    width: 100px; height: 100px;
    border-radius: 16px;
    background: var(--white);
    border: 4px solid var(--white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex; align-items: center; justify-content: center;
    font-size: 40px; font-weight: 700; color: var(--brand-primary);
    overflow: hidden; flex-shrink: 0;
}
.hero-logo img { width: 100%; height: 100%; object-fit: contain; background: var(--white); }
.hero-text { flex: 1; min-width: 200px; padding-top: 50px; }
.hero-text h2 { font-size: 22px; }
.hero-text p { color: var(--muted); margin-top: 2px; }
.hero-user { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--bg); border-radius: 30px; }
.hero-user .avatar { width: 40px; height: 40px; }
.hero-user small { display: block; color: var(--muted); font-size: 12px; }

.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 18px; }
.card-head .section-title { display: flex; align-items: center; gap: 10px; }
.card-icon {
    width: 34px; height: 34px; border-radius: 8px;
    background: var(--brand-primary-light);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 17px;
}

.card-section .edit-mode { display: none; }
.card-section.editing .edit-mode { display: block; }
.card-section.editing .view-mode { display: none; }
.card-section.editing .edit-btn { display: none; }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 24px; }
.info-item .info-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); font-weight: 600; }
.info-item .info-value { margin-top: 4px; font-size: 15px; font-weight: 500; word-break: break-word; }
.info-item.wide { grid-column: span 2; }
.info-value.empty-value { color: #9ca3af; font-weight: 400; font-style: italic; }

.uploader { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.uploader-preview {
    width: 84px; height: 84px; border-radius: 14px;
    border: 1px dashed var(--border);
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    font-size: 30px; font-weight: 700; color: var(--brand-primary);
    overflow: hidden; flex-shrink: 0;
}
.uploader-preview.round { border-radius: 50%; }
.uploader-preview img { width: 100%; height: 100%; object-fit: contain; }
.uploader-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.uploader .hint { width: 100%; font-size: 12px; color: var(--muted); }
.visually-hidden { display: none; }

.security-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.security-row:last-of-type { border-bottom: none; }
.security-row .info-value { margin-top: 2px; }
.inline-form { display: none; width: 100%; padding: 16px; background: var(--bg); border-radius: 10px; margin-top: 4px; }
.inline-form.open { display: block; }

/* ---------- Customers ---------- */
.customer-cell { display: flex; align-items: center; gap: 10px; }
.customer-cell .avatar { width: 34px; height: 34px; font-size: 14px; }
.amount-due { color: var(--danger); font-weight: 700; }
.amount-clear { color: var(--success); font-weight: 600; }

/* ---------- Invoice and receipt ---------- */
.invoice { color: #111827; font-size: 13px; position: relative; }
.invoice-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 3px solid var(--brand-primary); flex-wrap: wrap; }
.invoice-company { display: flex; gap: 14px; align-items: center; }
.invoice-logo { width: 64px; height: 64px; object-fit: contain; border-radius: 10px; flex-shrink: 0; }
.invoice-logo-text {
    background: var(--brand-primary); color: var(--white);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 700;
}
.invoice-company-name { font-size: 20px; font-weight: 700; }
.invoice-company-meta { color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.5; }
.invoice-title { text-align: right; }
.invoice-title h2 { font-size: 26px; color: var(--brand-primary); letter-spacing: 1px; }

.invoice-meta { display: flex; justify-content: space-between; gap: 20px; margin: 20px 0; flex-wrap: wrap; }
.invoice-block.right { text-align: right; }
.invoice-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.invoice-section { margin-top: 22px; }
.invoice-strong { font-weight: 700; font-size: 15px; }
.invoice-muted { color: var(--muted); font-size: 12px; }

.invoice-table { width: 100%; border-collapse: collapse; }
.invoice-table th { background: var(--brand-primary-light); color: var(--brand-primary-dark); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; text-align: left; padding: 9px 10px; }
.invoice-table td { padding: 10px; border-bottom: 1px solid var(--border); }
.invoice-table .num { text-align: right; }
.invoice-table.compact td, .invoice-table.compact th { padding: 6px 10px; }

.invoice-bottom { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-top: 16px; flex-wrap: wrap; }
.invoice-totals { min-width: 260px; margin-left: auto; }
.invoice-line { display: flex; justify-content: space-between; padding: 5px 0; }
.invoice-line.grand { font-size: 16px; font-weight: 700; border-top: 2px solid var(--dark); margin-top: 4px; padding-top: 8px; }
.invoice-line.due { font-weight: 700; color: var(--danger); }
.invoice-footer { text-align: center; color: var(--muted); border-top: 1px dashed var(--border); margin-top: 24px; padding-top: 14px; }

.stamp {
    display: inline-block;
    border: 3px solid;
    border-radius: 8px;
    padding: 4px 16px;
    font-size: 20px; font-weight: 800; letter-spacing: 2px;
    transform: rotate(-6deg);
    margin-top: 10px;
}
.stamp-paid { color: var(--success); border-color: var(--success); }
.stamp-partial { color: var(--warning); border-color: var(--warning); }
.stamp-due { color: var(--danger); border-color: var(--danger); }

.receipt-amount {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--success-light); color: #166534;
    padding: 14px 16px; border-radius: 10px; margin-bottom: 16px;
}
.receipt-amount strong { font-size: 24px; }

/* ---------- Login ---------- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card {
    background: var(--white);
    padding: 32px;
    border-radius: 14px;
    width: 92%; max-width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}
.auth-card .brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 16px; }
.auth-card .brand-name { color: var(--dark); }
.auth-card h2 { text-align: center; font-size: 18px; margin-bottom: 18px; }
.auth-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.auth-note { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .pos-layout { grid-template-columns: 110px 1fr 320px; }
    .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .app { height: auto; min-height: 100vh; }
    .content-pos { overflow: visible; }
    .pos-layout { grid-template-columns: 1fr; height: auto; }
    .categories { display: flex; gap: 8px; overflow-x: auto; }
    .category-btn { min-width: 100px; margin-bottom: 0; }
    .product-grid { max-height: 60vh; }
    .cart { min-height: 420px; }
    .products .panel-tools input { width: 100%; }
    .info-grid { grid-template-columns: 1fr 1fr; }
    .info-item.wide { grid-column: span 2; }
    .hero-text { padding-top: 0; }
}
@media (max-width: 560px) {
    .info-grid { grid-template-columns: 1fr; }
    .info-item.wide { grid-column: auto; }
    .invoice-title { text-align: left; }
    .invoice-block.right { text-align: left; }
}

/* ---------- Print: only the invoice ---------- */
@media print {
    body * { visibility: hidden; }
    .invoice, .invoice * { visibility: visible; }
    .invoice { position: absolute; left: 0; top: 0; width: 100%; }
    .modal { background: none; }
    .no-print { display: none !important; }
}
