/* ══════════════════════════════════════════════════════════════
   shared.css — Unified design system for Evercoast Quote Engine
   Used by: admin.html, quote.html, and PDF generation (server.js)
   ══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Poppins:wght@300;400;500;600&display=swap');

/* ── Design Tokens ── */
:root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --surface-alt: #f8f9fa;
    --border: #e5e7eb;
    --border-light: #e8e9ec;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --accent: #141414;
    --green: #059669;
    --green-bg: #ecfdf5;
    --red: #dc2626;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.08);
    --sec-1: #1f2937;
}

/* ── Reset & Base ── */
* { margin: 0; padding: 0; box-sizing: border-box; }
input, button, select, textarea { font-family: inherit; }
select { font-family: 'Inter', -apple-system, sans-serif; }

body {
    font-family: 'Poppins', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* headings inherit Poppins from body */

/* ── Page Container ── */
.page {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

/* ── Hero ── */
.hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 32px;
    margin-bottom: 32px;
}

.hero-left { flex: 1; min-width: 0; }

.eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.hero h1 { font-size: 28px; font-weight: 600; line-height: 1.2; }

.hero-desc {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 600px;
    line-height: 1.65;
    margin-top: 10px;
}

/* ── EC-44 Badge ── */
.ec44-badge {
    flex-shrink: 0;
    width: 130px;
    height: 130px;
    border-radius: 16px;
    background: var(--accent);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.ec44-badge::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, transparent 60%);
}

.ec44-badge .badge-prefix {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.18em;
    margin-right: -0.36em;
    text-transform: uppercase;
    opacity: 0.85;
    position: relative;
}

.ec44-badge .badge-number {
    font-size: 52px;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.03em;
    position: relative;
}

/* ── Title row (title + SKU tag inline) ── */
.title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sku-tag {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Architecture ── */
.arch-section { margin-bottom: 32px; }
.arch-section .section-note { margin-top: 0; }

.arch-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.arch-frame {
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.arch-frame .zoom-icon {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 28px;
    height: 28px;
    background: rgba(255,255,255,0.75);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    pointer-events: none;
}

.arch-frame .zoom-icon svg { width: 14px; height: 14px; stroke: rgba(0,0,0,0.5); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.15s ease; }
.arch-frame:hover .zoom-icon { background: rgba(255,255,255,0.95); }
.arch-frame:hover .zoom-icon svg { stroke: rgba(0,0,0,0.8); }
.arch-frame img { width: 100%; display: block; }

/* ── Highlights ── */
.highlights-section { margin-bottom: 36px; }

.highlights-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.section-note {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.65;
    max-width: 680px;
    margin-top: 0;
    margin-bottom: 20px;
    white-space: pre-line;
}

.highlights-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.highlight-card {
    background: var(--surface);
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

.highlight-card:nth-child(3n) { border-right: none; }
.highlight-card:nth-last-child(-n+3) { border-bottom: none; }

.highlight-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.highlight-icon svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-secondary);
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.highlight-text {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.45;
}

/* ── Lightbox ── */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.92);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.lightbox.open { display: flex; }
.lightbox img { max-width: 95vw; max-height: 90vh; object-fit: contain; }
.lightbox-close { position: absolute; top: 20px; right: 24px; font-size: 28px; color: white; cursor: pointer; opacity: 0.7; background: none; border: none; }
.lightbox-close:hover { opacity: 1; }

/* ── Sections ── */
.section-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.sections-container { margin-top: 20px; font-family: 'Inter', -apple-system, sans-serif; }
.components-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }

.btn-expand-all {
    font-size: 11px; font-weight: 600;
    color: var(--text-muted); background: none; border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 4px 10px; cursor: pointer; transition: all 0.15s;
}
.btn-expand-all:hover { color: var(--text-secondary); border-color: var(--text-muted); }

.section { margin-bottom: 28px; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--sec-1);
}

.section-title { font-size: 15px; font-weight: 600; }

/* ── Quote Table ── */
.quote-table { width: 100%; border-collapse: collapse; }

.quote-table thead th {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 2px 0 8px;
    text-align: right;
    border-bottom: 1px solid var(--border-light);
}

.quote-table thead th:first-child { text-align: left; }

.quote-table tbody td {
    padding: 12px 0;
    font-size: 13px;
    text-align: right;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    line-height: 1.5;
}

.quote-table tbody td:first-child { text-align: left; padding-right: 12px; }

.item-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.item-name { font-weight: 500; color: var(--text); }
.item-spec { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.price-cell { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.total-cell { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── Expandable Detail ── */
.detail-row td {
    padding: 0 !important;
    border-bottom: 1px solid var(--border-light) !important;
}

.detail-wrapper {
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.25s ease;
}

.detail-inner {
    padding: 14px 0 18px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.detail-pair {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.detail-pair.reverse { flex-direction: row-reverse; }

.detail-pair img {
    flex: 0 0 50%;
    width: 50%;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border-light);
}

.detail-pair .detail-content {
    flex: 1;
    min-width: 0;
    padding-top: 6px;
}

.detail-pair .detail-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.detail-pair .detail-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-line;
}

.detail-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s;
}
.detail-link-btn:hover { background: var(--surface-alt); color: var(--text); border-color: #d1d5db; }
.detail-link-btn svg { width: 11px; height: 11px; }

/* ── Subtotal ── */
.subtotal-row td { border-bottom: none !important; padding-top: 10px !important; }
.subtotal-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.subtotal-value { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Grand Total ── */
.grand-total {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 36px;
    overflow: hidden;
}

.grand-total-top {
    padding: 28px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.grand-total-left h3 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text);
}

.grand-total-left p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.grand-total-amount {
    font-size: 36px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    color: var(--text);
}

/* Split total grid — used when multiple billing types */
.grand-total-grid {
    display: flex;
    width: 100%;
}

.grand-total-cell {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px 16px;
}

.grand-total-cell + .grand-total-cell {
    border-left: 1px solid var(--border);
}

.grand-total-cell-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.grand-total-cell-value {
    font-size: 26px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    color: var(--text);
    white-space: nowrap;
}

.grand-total-cell-value .suffix {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0;
}

.breakdown {
    display: flex;
    flex-wrap: wrap;
    border-top: 1px solid var(--border);
}

.breakdown-pill {
    flex: 1 1 auto;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 14px 10px;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.breakdown-pill:last-child { border-right: none; }

.breakdown-pill .pill-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

/* ── Logo Link ── */
.logo-link {
    display: inline-flex;
    align-items: center;
    position: relative;
    text-decoration: none;
}
.logo-link img { transition: opacity 0.15s; }
.logo-link:hover img { opacity: 0.6; }

.logo-link .logo-tooltip {
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%) translateY(6px);
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 100;
}
.logo-link .logo-tooltip::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -4px;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid var(--accent);
}
.logo-link:hover .logo-tooltip { opacity: 1; }

/* ── Footer ── */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 48px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.copyright {
    font-size: 11px;
    color: var(--text-muted);
}

.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.footer-link:hover { color: var(--text-secondary); }

.footer-date { font-size: 11px; color: var(--text-muted); }

.footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Modal ── */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-backdrop.open { display: flex; }

.modal-dialog {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.15s ease;
}

.modal-dialog h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.modal-dialog p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 22px;
}

.modal-btns {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.modal-btns button {
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: all 0.15s;
}

.modal-btns button:hover { background: var(--surface-alt); }
.modal-btns .btn-danger { color: #dc2626; }
.modal-btns .btn-danger:hover { background: #fef2f2; }

/* ── Animations ── */
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Shared Responsive ── */
@media (max-width: 640px) {
    .page { padding: 20px 16px 60px; }
    .hero { flex-direction: column; }
    .hero h1 { font-size: 22px; }
    .ec44-badge { width: 100px; height: 100px; }
    .ec44-badge .badge-number { font-size: 40px; }
    .highlights-grid { grid-template-columns: 1fr; }
    .grand-total-top { flex-direction: column; gap: 16px; text-align: center; }
    .grand-total-amount { font-size: 28px; }
    .grand-total-grid { flex-direction: column; }
    .grand-total-cell + .grand-total-cell { border-left: none; border-top: 1px solid var(--border); }
    .grand-total-cell { padding: 18px 16px; }
    .grand-total-cell-value { font-size: 22px; }
    .breakdown { flex-direction: column; }
    .breakdown-pill { border-right: none; min-width: 0; }
    .breakdown-pill:last-child { border-bottom: none; }
    .detail-pair, .detail-pair.reverse { flex-direction: column; }
    .detail-pair img { flex: none; width: 100%; }
}
