/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --brand:       #1a73e8;
    --brand-dark:  #1557b0;
    --bg:          #f5f7fa;
    --surface:     #ffffff;
    --border:      #e0e4eb;
    --text:        #1c1e21;
    --muted:       #6b7280;
    --success:     #16a34a;
    --error:       #dc2626;
    --radius:      12px;
    --shadow:      0 2px 12px rgba(0,0,0,0.08);
}

html, body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Header ── */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner { max-width: 720px; width: 100%; margin: 0 auto; }

.header-logo {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--brand);
}

/* ── Main content ── */
.main-content {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ── Page heading ── */
.lookup-container h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.subtitle {
    color: var(--muted);
    margin-bottom: 1.75rem;
    font-size: 0.95rem;
}

/* ── Input card ── */
.input-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
    min-width: 160px;
}

.field-state { flex: 0 0 160px; }

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input[type="text"], select {
    height: 44px;
    padding: 0 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s;
    width: 100%;
}

input[type="text"]:focus, select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}

/* ── Divider ── */
.divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ── Result source note ── */
.result-source {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.75rem;
    font-style: italic;
}

/* ── Photo row ── */
.photo-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.photo-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1.5px dashed var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--brand);
    text-transform: none;
    letter-spacing: normal;
    transition: border-color 0.15s, background 0.15s;
}

.photo-label:hover {
    border-color: var(--brand);
    background: rgba(26,115,232,0.04);
}

.photo-label input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.ocr-status {
    font-size: 0.85rem;
    color: var(--muted);
    font-style: italic;
}

/* ── Lookup button ── */
.lookup-btn {
    height: 48px;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.lookup-btn:hover:not(:disabled) { background: var(--brand-dark); }
.lookup-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Result card ── */
.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-top: 1.5rem;
}

.result-card h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--success);
}

.result-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.result-row:last-child { border-bottom: none; }

.result-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    flex-shrink: 0;
}

.result-value {
    font-size: 0.95rem;
    color: var(--text);
    text-align: right;
    word-break: break-all;
}

/* ── Error card ── */
.error-card {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    color: var(--error);
    font-size: 0.9rem;
    margin-top: 1.25rem;
}

/* ── Enrichment prompt ── */
.enrich-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px dashed var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.enrich-prompt {
    font-size: 0.9rem;
    color: var(--muted);
    font-style: italic;
}

.enrich-btn {
    height: 40px;
    font-size: 0.9rem;
}

/* ── History section ── */
.history-section {
    margin-top: 1.5rem;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.history-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.clear-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.clear-btn:hover {
    color: var(--error);
    background: rgba(220, 38, 38, 0.06);
}

.history-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.history-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    background: rgba(26, 115, 232, 0.04);
}

.history-item-main {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.history-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.history-time {
    font-size: 0.75rem;
    color: var(--muted);
    flex-shrink: 0;
    margin-left: 1rem;
}

.history-subtitle {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.15rem;
    display: block;
}

/* ── Blazor internals ── */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--brand);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }
