/* ================================================================
   Online Receipt Maker — Global Styles
================================================================ */

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

/* ── Base ──────────────────────────────────────────────────────── */
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #eef0f4;
    color: #1a1a2e;
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3 { margin-top: 0; font-weight: 700; }

p { margin-top: 0; color: #4b5563; }

a { color: inherit; text-decoration: none; }

input, select, button, textarea { font: inherit; }

/* ── Header ────────────────────────────────────────────────────── */
.site-header {
    background: #141824;
    padding: 0;
    margin-bottom: 0;
}

.header-image {
    display: block;
    width: 100%;
    max-width: 1200px;
    height: 130px;
    object-fit: cover;
    object-position: left center;
    margin: 0 auto;
}

/* ── Homepage / Category container ─────────────────────────────── */
.container {
    max-width: 900px;
    margin: 36px auto;
    background: #fff;
    padding: 28px 30px;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
}

.container h1 { font-size: 1.6rem; margin-bottom: 4px; }

/* ── Card grid ──────────────────────────────────────────────────── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-top: 22px;
}

.card {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px 18px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    transition: transform 0.13s ease, box-shadow 0.13s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10);
}

.category-card { display: block; cursor: pointer; }

/* Each column spans 2 row tracks and uses subgrid so the info card
   and preview card share the same row heights across all columns. */
.template-column {
    display: grid;
    grid-row: span 2;
    grid-template-rows: subgrid;
    min-width: 0;
}

.template-card {
    display: flex;
    flex-direction: column;
}

.template-card .button,
.template-card .coming-soon-btn {
    margin-top: auto;
    align-self: flex-start;
}

.coming-soon-btn {
    background: #94a3b8;
    color: #fff;
    cursor: default;
    opacity: 0.7;
}

.preview-card {
    padding: 8px;
    overflow: hidden;
    height: 300px;
}

.preview-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    border-radius: 4px;
}

.card h2 { font-size: 1.1rem; margin-bottom: 6px; }

.card p { margin: 0; font-size: 0.87rem; color: #6b7280; }

/* "Back to categories" row */
.page-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.button, button {
    display: inline-block;
    padding: 9px 18px;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
    transition: filter 0.12s ease, opacity 0.12s ease;
}

.button:hover, button:hover { filter: brightness(1.1); }

.primary-btn,
.button:not(.secondary-btn) { background: #1d4ed8; color: #fff; }

.secondary-btn { background: #64748b; color: #fff; }

/* ── Form page ──────────────────────────────────────────────────── */
.form-page {
    max-width: 620px;          /* narrower, more focused */
    margin: 28px auto 60px;
    padding: 0 14px;
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e5e7eb;
}

.form-header h1 { font-size: 1.2rem; margin-bottom: 2px; }

.form-header p { margin: 0; font-size: 0.82rem; color: #6b7280; }

/* ── Form sections ──────────────────────────────────────────────── */
.form-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px 18px 14px;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.section-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    margin-bottom: 12px;
    padding-bottom: 7px;
    border-bottom: 1px solid #e2e8f0;
}

/* ── Field rows ─────────────────────────────────────────────────── */
.field-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.field-row:last-child { margin-bottom: 0; }

.field-row.two-col   { grid-template-columns: repeat(2, 1fr); }
.field-row.three-col { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 540px) {
    .field-row.two-col,
    .field-row.three-col { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; min-width: 0; }

.field label {
    font-size: 0.77rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
    letter-spacing: 0.01em;
}

.field label .optional {
    font-weight: 400;
    color: #94a3b8;
    font-size: 0.73rem;
    margin-left: 3px;
}

.field input,
.field select {
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #f8fafc;
    font-size: 0.9rem;
    transition: border-color 0.12s ease, background 0.12s ease;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: #1d4ed8;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.08);
}

.field input[type="file"] {
    padding: 5px 8px;
    background: #fff;
    font-size: 0.85rem;
}

/* ── Item rows ──────────────────────────────────────────────────── */
.item-header-row,
.item-row {
    display: grid;
    grid-template-columns: 52px 1fr 1fr 82px 32px;
    gap: 7px;
    align-items: center;
}

.item-header-row {
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-bottom: 7px;
    border-bottom: 1px dashed #e2e8f0;
    margin-bottom: 8px;
}

.item-row { margin-bottom: 8px; }

.item-row input {
    padding: 7px 9px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #f8fafc;
    font-size: 0.88rem;
    width: 100%;
    transition: border-color 0.12s ease;
}

.item-row input:focus {
    outline: none;
    border-color: #1d4ed8;
    background: #fff;
}

.btn-remove {
    width: 30px;
    height: 30px;
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.12s ease;
}

.btn-remove:hover {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
    filter: none;
}

.add-item-btn {
    margin-top: 10px;
    padding: 7px 14px;
    font-size: 0.85rem;
}

@media (max-width: 540px) {
    .item-header-row,
    .item-row { grid-template-columns: 46px 1fr 30px; }

    .item-header-row span:nth-child(3),
    .item-header-row span:nth-child(4),
    .item-row input:nth-child(3),
    .item-row input:nth-child(4) { display: none; }
}

/* ── Form actions ───────────────────────────────────────────────── */
.form-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 6px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.form-actions .button,
.form-actions button { min-width: 150px; }

.primary-btn { background: #1d4ed8; }
.primary-btn:hover { background: #1e40af; filter: none; }
