:root {
    --bg: #0f1720;
    --bg-alt: #071026;
    --panel: #0b1220;
    --panel-alt: #081827;
    --accent: #06b6d4;
    --accent-soft: #1098a8;
	--warning-soft: #980202;
	--warning: #c80202;
    --text: #e6eef6;
    --text-muted: #98a0b3;
    --ok: #10b981;
    --danger: #ef4444;
}

body {
    margin: 0;
    padding: 0;
    font-family: "Inter", ui-sans-serif, system-ui, Arial, sans-serif;
    background: linear-gradient(180deg, var(--bg), var(--bg-alt));
    color: var(--text);
    overflow-x: hidden;
}

body2 {
	margin: 0;
	font-family: Arial, sans-serif;
}

#viewCanvasContainer {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: calc(100vh - 120px); /* leave space for control panel */
    gap: 16px;
    padding: 16px;
    box-sizing: border-box;
}

/* ---------------------------------------------------------
   LEFT: Large PCB Area (full height)
   --------------------------------------------------------- */

#leftImageArea {
    flex: 2;
    background: #111;
    padding: 10px;
    border-radius: 12px;
    /* box-shadow: 0 0 14px rgba(0,0,0,0.45); */

    display: flex;
    justify-content: center;
    align-items: center;
}

#canvas {
    /* width: 100%; */
    /* height: 100%; */
    object-fit: contain;
}

/* ---------------------------------------------------------
   RIGHT: Two stacked panels
   --------------------------------------------------------- */

#rightImageArea {
    /* flex: 1; */
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#bitfieldWrapper,
#heatmapWrapper {
    flex: 1;
    background: #111;
    padding: 5px;
    border-radius: 5px;

    display: flex;
    justify-content: center;
    align-items: center;
    object-fit: contain;
}

#bitfieldcanvas,
#heatmapcanvas {
    width: 100%; 
    height: 100%; 
}

/* ---------------------------------------------------------
   BOTTOM CONTROL PANEL
   --------------------------------------------------------- */

#bottomControlPanel {
    width: 100%;
    background: var(--panel-alt);
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 -3px 12px rgba(0,0,0,0.3);

    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
}

/* ---------------------------------------------------------
   RESPONSIVE FOR MOBILE
   --------------------------------------------------------- */

@media (max-width: 1200px) {
    #topArea {
        flex-direction: column;
        height: auto;
    }

    #leftImageArea { height: 40vh; }
    #rightImageArea { height: 40vh; }

    #bitfieldWrapper,
    #heatmapWrapper {
        /* height: 50%; */
    }
}


#uploadContainer {
	display: flex;
	background: var(--panel);
	flex-direction: column;
	align-items: center;
	justify-content: center;
	height: 100vh;
	/* background-color: #f0f0f0; */
}


#canvasContainer {
	display: none;
	background: var(--panel);
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: calc(100vh - 100px);
	/* background-color: #000; */
	box-sizing: border-box;
}

/*
#canvas {
	max-width: 100%;
	display: block;
	cursor: crosshair;
}
*/

/*
#bitfieldcanvas
{
	display: flex;
	align-items: right;
	justify-content: right;
	top: 0;
	right: 0;
	max-width: 30%;
	display: block;
	cursor: crosshair;
	align-items: center;

}
*/
#controlPanel {
	position: fixed;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 100px;
	background: var(--panel);
	/* background-color: #fff; 
	border-top: 2px solid #ccc;
	*/
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px;
	box-sizing: border-box;
	z-index: 10;
}
#leftControls, #rightControls {
	display: flex;
	align-items: center;
}
#classSelector, #actionSelector, #pcbNameInput, #submitButton {
	padding: 8px;
	margin-right: 15px;
}
#pcbNameInput {
	width: 200px;
	/* display: none; */
}

/* Headings */
h1, h2, h3 {
    margin-top: 0;
    color: var(--accent);
    letter-spacing: .5px;
}

/* Buttons */
button {
    background: var(--accent-soft);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    transition: background .15s ease, transform .1s ease;
	padding: 7px;
	margin-left: 5px;
	margin-right: 5px;
}

button:hover {
    background: var(--accent);
    transform: scale(1.03);
}

button:disabled {
    background: #1d2e3a;
    color: #556070;
    cursor: not-allowed;
    transform: none;
}

#submitButton:disabled {
	background: #ccc;
	cursor: not-allowed;
}

#deleteButton {
    background: var(--warning-soft);
}

#deleteButton:hover {
    background: var(--warning);
    transform: scale(1.03);
}

#messageArea {
	font-size: 16px;
	/* color: #333; */
	min-width: 200px;
	margin-left: 10px;
	margin-right: 10px;
}

/* Rotate Buttons */
#rotateLeftButton,
#rotateRightButton {
    background: #044b57;
}

#rotateLeftButton:hover,
#rotateRightButton:hover {
    background: #047b8a;
}

/* Submit / Identify / Train buttons */
#submitButton {
    /* background: var(--ok); */
    background: #0fab4c;
	
}
#submitButton:hover {
    background: #0fcb9c;
}

/* Error button example */
.btn-danger {
    background: var(--danger);
}
.btn-danger:hover {
    background: #ff6363;
}

.handle {
	position: absolute;
	width: 10px;
	height: 10px;
	background-color: #fff;
	border: 1px solid #000;
	cursor: pointer;
}

.pcb-list {
        margin-top: 10px;
}

.pcb-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: #020617;
        border: 1px solid #1e293b;
        border-radius: 6px;
        padding: 10px;
        margin-bottom: 6px;
}

.pcb-id {
        font-family: monospace;
        font-size: 0.95rem;
        color: #93c5fd;
}

.pcb-actions button {
        margin-left: 6px;
        padding: 4px 10px;
        background: #1e293b;
        border: 1px solid #334155;
        color: #e5e7eb;
        cursor: pointer;
        border-radius: 4px;
}

.pcb-actions button:hover {
        background: #2563eb;
        border-color: #2563eb;
}

.spinner-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0;
    font-size: 14px;
    opacity: 0.85;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 3px solid #666;
    border-top: 3px solid #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

    .topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 16px;
    }

    .spinner-wrap {
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 16px 0;
    }

    .spinner {
        width: 22px;
        height: 22px;
        border: 3px solid #666;
        border-top: 3px solid #fff;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
    }

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

    /* Match Card Styles */

    .match-card {
        /* border: 1px solid #333; */
        border-radius: 8px;
        padding: 12px;
        margin-bottom: 14px;
        background: #011212;
        color: #eee;
    }

    .match-header {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 8px;
    }

    .match-title {
        font-size: 18px;
        font-weight: bold;
    }

    .match-meta {
        font-size: 13px;
        opacity: 0.85;
    }

    .match-body {
        display: flex;
        gap: 14px;
        align-items: flex-start;
    }

    .match-img {
        width: 600px;
        max-height: 400px;
        object-fit: contain;
        background: #000;
        /* border: 1px solid #333; */
    }

    .score-box {
        line-height: 1.5;
        min-width: 260px;
    }

    details {
        margin-top: 8px;
    }

    summary {
        cursor: pointer;
        font-weight: bold;
    }

    .class-row {
        font-family: monospace;
        font-size: 12px;
        white-space: pre-wrap;
        border-top: 1px solid #333;
        padding: 4px 0;
    }

    .error {
        color: #ff8080;
        font-weight: bold;
    }
