/* css/base.css - rules shared by /resit, /invois and /sebutharga. Each page keeps its own rules in an inline <style> after this file. */

:root {
    --primary: #0f172a;
    --accent: #2563eb;
    --bg-body: #f1f5f9;
    --border: #e2e8f0;
    --text-main: #334155;
    --font-modern: 'Inter', sans-serif;
    --font-thermal: 'Inconsolata', monospace;
}

* {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    padding-bottom: 120px;
}

.hidden {
    display: none !important;
}

.brand {
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.5px;
    color: var(--primary);
    display: flex;
    align-items: center;
}

/* --- LANGUAGE TOGGLE (document output language, always visible) --- */
.lang-toggle {
    display: flex;
    align-items: center;
    background: #e2e8f0;
    padding: 2px 4px 2px 6px;
    border-radius: 8px;
    margin-left: 10px;
    gap: 2px;
}

.lang-toggle-icon {
    width: 13px;
    height: 13px;
    color: #64748b;
    margin-right: 2px;
    flex-shrink: 0;
}

.lang-toggle-btn {
    padding: 4px 10px;
    border: none;
    background: transparent;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    border-radius: 6px;
    transition: 0.15s;
}

.lang-toggle-btn.active {
    background: white;
    color: var(--accent);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* --- TOP BAR ACTIONS (ported from index.html) --- */
.top-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    position: relative;
}

.icon-btn svg {
    width: 14px;
    height: 14px;
}

/* The navigation items are links and the actions are buttons; they must not
   look different because of that. */
.icon-btn {
    font-family: inherit;
    text-decoration: none;
}

.icon-btn:hover {
    background: #f1f5f9;
}

.new-dot {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border: 1.5px solid white;
    border-radius: 50%;
}

.icon-btn.primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.icon-btn.primary:hover {
    background: #1d4ed8;
}

/* --- LAYOUT --- */
.app-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* --- BASE FORM CONTROLS (reused from index.html; populated in a later task) --- */
.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 14px;
    font-family: inherit;
}

/* Payment Grid (reused here for the feedback-vote radios) */
.pay-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.pay-opt {
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}

.pay-radio:checked+.pay-opt {
    background: #eff6ff;
    border-color: var(--accent);
    color: var(--accent);
}

.pay-radio {
    display: none;
}

/* Soalan Lazim - same pattern as index.html: placed directly above the
   feedback form, because someone who cannot find a control scrolls
   down to complain and this is the last thing they pass. */
.faq-wrap {
    max-width: 1000px;
    margin: 32px auto 0;
    padding: 0 20px;
}

.faq-item {
    border-bottom: 1px solid var(--border);
}

.faq-item:last-of-type {
    border-bottom: 0;
}

.faq-item summary {
    cursor: pointer;
    list-style: none;
    padding: 12px 28px 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    position: relative;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: "+";
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    font-weight: 400;
    color: var(--primary);
    line-height: 1;
}

.faq-item[open] summary::after {
    content: "−";
}

.faq-item p {
    margin: 0 0 14px;
    font-size: 13px;
    line-height: 1.65;
    color: #64748b;
}

/* Feedback + Contact row - mirrors index.html's engage-row. */
.engage-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    max-width: 1000px;
    margin: 32px auto 0;
    padding: 0 20px;
}

.promo-card {
    margin-top: 20px;
    background: #fff7ed;
    border: 1px solid #fdba74;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.btn-main {
    background: var(--primary);
    color: white;
    border: none;
    width: 100%;
    max-width: 480px;
    height: 50px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: 0.2s;
}

.btn-main:active {
    transform: scale(0.98);
}

/* --- FOOTER --- */
.fixed-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    /* side by side - two stacked buttons made the bar eat half a
       phone screen */
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 8px;
    z-index: 200;
}

.fixed-footer .btn-main {
    width: auto;
    flex: 1 1 0;
    max-width: 240px;
}

.field-label {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 4px;
}

/* --- ITEM ROWS + CATALOG PICKER (ported from index.html) --- */
/* Item card (issue #48). Two lines at EVERY width, because the form column is
   only 223-494px wide on phones and desktops alike. Line 1 mirrors the printed
   receipt (name ... line amount); line 2 is the maths: [qty | unit] x [price].
   No @media here on purpose (see CLAUDE.md). */
.item-row {
    display: grid;
    /* Two zones. Left = the fields: line 1 the item name, line 2 the maths
       [qty | unit] x [price]; name and price share one right edge. Right = a
       fixed 68px gutter for the delete action (line 1) and the line amount
       (line 2, room for "12,500.00"), both flush right. So every card has the
       same four edges whatever its numbers. Narrowest list (223px, 320px
       phone): 76 + 10 + 48 + 68 + 3 x 4 = 214; spare width grows qty first
       (to 104px), then the price. */
    grid-template-columns: minmax(76px, 104px) 10px minmax(48px, 1fr) 68px;
    grid-template-areas:
        "name name name  del"
        "qty  x    price amt";
    column-gap: 4px;
    row-gap: 6px;
    align-items: center;
    padding: 10px 0;
}

.item-row:first-child {
    padding-top: 0;
}

.item-row + .item-row {
    border-top: 1px solid var(--border);
}

.item-row > .item-name {
    grid-area: name;
    margin: 0;
    min-width: 0;
}

.item-row > .item-amount {
    grid-area: amt;
    justify-self: end;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.item-row > .item-amount.is-empty {
    color: #cbd5e1;
}

.item-row > .item-del {
    grid-area: del;
    justify-self: end;
    align-self: stretch;
    width: 24px;
}

.item-row > .qty-group {
    grid-area: qty;
}

.item-row > .item-times {
    grid-area: x;
    text-align: center;
    font-size: 13px;
    color: #94a3b8;
}

/* fills its track, so it ends exactly where the item name ends */
.item-row > .item-price {
    grid-area: price;
    margin: 0;
    min-width: 0;
    padding-left: 8px;
    padding-right: 6px;
    /* left, next to the x sign, like every other money input on the form */
    text-align: left;
}

/* Quantity and its optional unit read as one value ("3.4 kg"), so they share
   one bordered box with a hairline between them. */
.qty-group {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    overflow: hidden;
}

.qty-group:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.qty-group input {
    min-width: 0;
    margin: 0;
    padding: 10px 4px;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
}

/* number and unit split the box evenly: "3.405" and "meter" both need ~45px */
.qty-num {
    flex: 1 1 0;
    width: 0;
    font-size: 14px;
    text-align: center;
    -moz-appearance: textfield;
}

/* the spinner ate a third of the box and hid "3.405"; phones never show it */
.qty-num::-webkit-inner-spin-button,
.qty-num::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.qty-unit {
    flex: 1 1 0;
    width: 0;
    border-left: 1px solid var(--border) !important;
    font-size: 13px;
    color: #475569;
    text-align: center;
}

/* a hint, not a disabled field: dark enough to be read on a phone in sunlight */
.qty-unit::placeholder {
    color: #94a3b8;
}

.item-del {
    border: none;
    background: none;
    color: #ef4444;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.item-del:disabled {
    color: #cbd5e1;
    cursor: not-allowed;
}

/* --- MODAL (catalog picker) --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 500;
    display: flex;
    justify-content: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-panel {
    background: white;
    width: 100%;
    max-width: 440px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}

.modal-overlay.open .modal-panel {
    transform: translateX(0);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #64748b;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

/* --- CHANGELOG --- */
.changelog-entry {
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.5;
}

.changelog-entry:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.changelog-date {
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 6px;
}

.changelog-entry ul {
    padding-left: 20px;
    margin: 0;
}

.changelog-entry li {
    margin-bottom: 4px;
}

/* --- HISTORY LIST (ported from index.html) --- */
.history-empty {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.history-empty-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #64748b;
}

.history-empty-sub {
    font-size: 12px;
}

.history-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: 0.15s;
    position: relative;
}

.history-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

.history-card-meta {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.history-card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px dashed var(--border);
    padding-top: 8px;
    margin-top: 4px;
}

.history-card-total {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
}

.history-card-del {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 4px;
}

.history-card-del:hover {
    color: #ef4444;
    background: #fef2f2;
}

.history-summary {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.clear-all-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

.pick-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.pick-tab {
    flex: 0 0 auto;
    padding: 5px 12px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    white-space: nowrap;
}

.pick-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pick-step {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    line-height: 1;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Isi Contoh picker (issue #48) */
.sample-intro {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 12px;
}

.sample-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.sample-option:hover,
.sample-option:focus-visible {
    border-color: var(--accent);
    background: #f8fafc;
}

.sample-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
}

.sample-hint {
    font-size: 12px;
    color: #64748b;
}
