/* ===== PCB Green on White Theme ===== */
:root {
    --pcb-green-dark: #0d5a1e;
    --pcb-green: #1a7a2e;
    --pcb-green-light: #2d8a46;
    --pcb-green-pale: #3ba55d;
    --pcb-green-faint: rgba(26, 122, 46, 0.06);
    --pcb-green-border: rgba(26, 122, 46, 0.18);
    --pcb-gold: #b8941f;
    --pcb-gold-light: #d4af37;
    --pcb-trace: rgba(26, 122, 46, 0.07);
    --pcb-copper: #b87333;
    --pcb-red: #c0392b;
    --pcb-bg: #ffffff;
    --pcb-card: #ffffff;
    --pcb-surface: #f8faf8;
    --pcb-text: #0d5a1e;
    --pcb-text-muted: #3a7a4a;
    --pcb-border: rgba(26, 122, 46, 0.2);
}

/* Override Pico light theme */
[data-theme="light"] {
    --pico-primary: var(--pcb-green);
    --pico-primary-hover: var(--pcb-green-dark);
    --pico-primary-focus: rgba(26, 122, 46, 0.15);
    --pico-background-color: var(--pcb-bg);
    --pico-card-background-color: var(--pcb-card);
    --pico-card-border-color: var(--pcb-border);
    --pico-color: var(--pcb-text);
    --pico-muted-color: var(--pcb-text-muted);
    --pico-muted-border-color: var(--pcb-border);
}

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

/* ===== PCB Trace Background Pattern ===== */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(var(--pcb-trace) 1px, transparent 1px),
        linear-gradient(90deg, var(--pcb-trace) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.6;
}

/* ===== Header ===== */
header.container {
    border-bottom: 2px solid var(--pcb-green);
    padding-bottom: 0.5rem;
    margin-bottom: 2rem;
}

header nav .logo-text {
    color: var(--pcb-green-dark);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-decoration: none;
    text-transform: uppercase;
}

header nav .logo-text:hover {
    color: var(--pcb-green);
}

header nav .tagline {
    color: var(--pcb-text-muted);
    font-size: 0.85rem;
}

/* ===== Cards / Articles ===== */
article {
    background: var(--pcb-card);
    border: 1px solid var(--pcb-border);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(26, 122, 46, 0.06);
}

/* ===== Drop Zone ===== */
.drop-zone {
    border: 2px dashed var(--pcb-green-light);
    border-radius: 8px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--pcb-surface);
    position: relative;
}

.drop-zone::before {
    content: "";
    display: block;
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='none' stroke='%231a7a2e' stroke-width='2'%3E%3Crect x='8' y='12' width='48' height='40' rx='4'/%3E%3Ccircle cx='20' cy='22' r='3'/%3E%3Ccircle cx='44' cy='22' r='3'/%3E%3Ccircle cx='20' cy='42' r='3'/%3E%3Ccircle cx='44' cy='42' r='3'/%3E%3Cline x1='20' y1='25' x2='20' y2='39'/%3E%3Cline x1='23' y1='22' x2='41' y2='22'/%3E%3Cline x1='44' y1='25' x2='44' y2='39'/%3E%3Cline x1='23' y1='42' x2='41' y2='42'/%3E%3Crect x='28' y='28' width='8' height='8' rx='1' fill='%231a7a2e'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--pcb-green);
    background: var(--pcb-green-faint);
    box-shadow: 0 0 20px rgba(26, 122, 46, 0.1);
}

.drop-zone p {
    margin: 0.5rem 0;
    color: var(--pcb-text-muted);
}

.drop-zone input[type="file"] {
    margin-top: 0.5rem;
}

/* ===== Buttons ===== */
button[type="submit"],
[role="button"] {
    background: var(--pcb-green);
    border-color: var(--pcb-green);
    color: #fff;
    font-weight: 600;
    transition: all 0.2s;
}

button[type="submit"]:hover,
[role="button"]:hover {
    background: var(--pcb-green-dark);
    border-color: var(--pcb-green-dark);
    box-shadow: 0 2px 8px rgba(26, 122, 46, 0.25);
}

[role="button"].contrast {
    background: var(--pcb-gold);
    border-color: var(--pcb-gold);
    color: #fff;
}

[role="button"].contrast:hover {
    background: var(--pcb-gold-light);
    border-color: var(--pcb-gold-light);
}

/* ===== Tables ===== */
table {
    border-collapse: collapse;
}

table td {
    border-color: var(--pcb-border);
    padding: 0.5rem 0.75rem;
    color: var(--pcb-text);
}

table td:first-child {
    color: var(--pcb-text-muted);
    font-weight: 500;
}

/* ===== Forms ===== */
select, input, textarea {
    background: var(--pcb-surface) !important;
    border-color: var(--pcb-border) !important;
    color: var(--pcb-text) !important;
}

select:focus, input:focus, textarea:focus {
    border-color: var(--pcb-green) !important;
    box-shadow: 0 0 0 3px rgba(26, 122, 46, 0.12) !important;
}

label {
    color: var(--pcb-text-muted);
    font-weight: 500;
}

/* ===== Price Display ===== */
#price-display {
    padding: 1.25rem;
    background: var(--pcb-green-faint);
    border: 1px solid var(--pcb-green-light);
    border-radius: 8px;
    text-align: center;
    color: var(--pcb-green-dark);
    font-weight: 700;
    font-size: 1.1rem;
}

/* ===== Order Section ===== */
#order-section {
    text-align: center;
}

/* ===== Progress ===== */
progress {
    accent-color: var(--pcb-green);
}

/* ===== Status Mark ===== */
mark {
    background: var(--pcb-green);
    color: #fff;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

/* ===== Error States ===== */
.error-text {
    color: var(--pcb-red);
}

.error-box {
    background: rgba(192, 57, 43, 0.08);
    border: 1px solid var(--pcb-red);
    color: var(--pcb-red);
    padding: 1rem;
    border-radius: 8px;
}

/* ===== Utility ===== */
.hidden {
    display: none !important;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--pcb-text-muted);
    opacity: 0.6;
    border-top: 1px solid var(--pcb-border);
    margin-top: 2rem;
}

/* ===== Headings ===== */
h2, h3, h4 {
    color: var(--pcb-green-dark);
}

h2 {
    border-bottom: 2px solid var(--pcb-border);
    padding-bottom: 0.5rem;
}

/* ===== Links ===== */
a {
    color: var(--pcb-green);
}

a:hover {
    color: var(--pcb-green-dark);
}

/* ===== PCB Preview ===== */
.pcb-preview-container {
    margin-top: 1rem;
    text-align: center;
}

.pcb-preview-container img {
    max-width: 100%;
    max-height: 400px;
    border: 1px solid var(--pcb-border);
    border-radius: 8px;
    background: #fff;
    padding: 0.5rem;
}

/* ===== PCB Dual Preview (Front + Back) ===== */
.pcb-preview-dual {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    justify-content: center;
}

.pcb-preview-side {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.pcb-preview-side img {
    max-width: 100%;
    max-height: 350px;
    border: 1px solid var(--pcb-border);
    border-radius: 8px;
    background: #fff;
    padding: 0.5rem;
}

.pcb-side-label {
    display: inline-block;
    background: var(--pcb-green);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ===== PCB Zoom Viewport ===== */
.pcb-zoom-viewport {
    width: 100%;
    height: 350px;
    border: 1px solid var(--pcb-border);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    cursor: grab;
    position: relative;
    touch-action: none;
}

.pcb-zoom-viewport:active {
    cursor: grabbing;
}

.pcb-zoom-viewport svg {
    transform-origin: 0 0;
    pointer-events: none;
}

.pcb-zoom-hint {
    text-align: center;
    color: var(--pcb-text-muted);
    font-size: 0.8rem;
    margin-top: 0.5rem;
    opacity: 0.7;
}

.pcb-zoom-controls {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 0.4rem;
}

.pcb-zoom-controls button {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    border-radius: 6px;
    background: var(--pcb-surface);
    border: 1px solid var(--pcb-border);
    color: var(--pcb-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pcb-zoom-controls button:hover {
    background: var(--pcb-green-faint);
    border-color: var(--pcb-green);
    box-shadow: none;
}

@media (max-width: 768px) {
    .pcb-preview-dual {
        flex-direction: column;
    }
    .pcb-zoom-viewport {
        height: 280px;
    }
}

#pcb-preview h4 {
    margin-top: 1.5rem;
}

/* ===== Responsive grid tweaks ===== */
@media (max-width: 768px) {
    .drop-zone {
        padding: 2rem 1rem;
    }
}
