@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('lib/fonts/outfit-300.ttf') format('truetype');
}

@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('lib/fonts/outfit-400.ttf') format('truetype');
}

@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('lib/fonts/outfit-600.ttf') format('truetype');
}

@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('lib/fonts/outfit-700.ttf') format('truetype');
}

:root {
    --bg-dark: #0f172a;
    --panel-bg: rgba(15, 23, 42, 0.95);
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-primary: #6366f1;
    --accent-hover: #4f46e5;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --crosshair-color: #ff9800;
    --white: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-primary) var(--bg-dark);
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* SIDEBAR */
.sidebar {
    width: 340px;
    background: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.step-num {
    background: rgba(255, 255, 255, 0.05);
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 0.6rem;
}

/* INPUTS & CONTROLS */
.control-group {
    background: rgba(255, 255, 255, 0.02);
    padding: 0.85rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.input-row {
    display: flex;
    gap: 0.5rem;
}

.input-wrapper {
    flex: 1;
}

.input-wrapper label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-bottom: 0.25rem;
}

.value-display {
    float: right;
    color: var(--accent-primary);
    font-weight: 600;
}

input[type="number"],
input[type="range"] {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    padding: 0.4rem;
    color: var(--text-main);
    font-size: 0.9rem;
}

input[type="range"] {
    padding: 0;
    height: 6px;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
}

/* CUSTOM CHECKBOX & TOGGLES */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px 0;
}

.checkbox-wrapper input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.checkbox-wrapper input[type="checkbox"]:checked {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.checkbox-wrapper input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 0.9rem;
    font-weight: bold;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* BUTTONS */
.btn {
    width: 100%;
    padding: 0.65rem;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-secondary.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-danger-active {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
    color: var(--danger);
}

.btn-outline-primary {
    background: rgba(99, 102, 241, 0.05);
    border: 1.5px dashed var(--accent-primary);
    color: var(--accent-primary);
    margin-top: 0.25rem;
    padding: 0.6rem;
}

.btn-outline-primary:hover {
    background: rgba(99, 102, 241, 0.12);
}

.btn-danger-ghost {
    color: var(--danger);
    background: transparent;
    border: 1px solid transparent;
    opacity: 0.7;
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.btn-danger-ghost:hover {
    border-color: var(--danger);
    opacity: 1;
    background: rgba(239, 68, 68, 0.05);
}

/* COLOR PICKER UI */
.color-preview-box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.color-display {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-dim);
    background: rgba(0, 0, 0, 0.2);
    padding: 8px;
    border-radius: 4px;
}

.color-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 0.75rem;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.color-suggestion-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.color-suggestion-btn:hover {
    transform: scale(1.15);
    border-color: white;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.color-suggestion-btn.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-primary);
}

/* DATASETS LIST */
.dataset-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 200px;
    overflow-y: auto;
}

.dataset-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 0.4rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: 0.2s;
}

.dataset-item.active {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

.dataset-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.65rem;
}

/* MAIN CANVAS AREA */
.main-area {
    flex: 1;
    background: #000;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

canvas {
    display: block;
    cursor: none;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    border: 1.5px dashed rgba(255, 255, 255, 0.15);
}

.upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 20;
    overflow-y: auto;
    padding: 4rem 1rem;
}

.upload-overlay.hidden {
    display: none;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    padding: 4rem;
    border-radius: 1.5rem;
    text-align: center;
    color: var(--text-dim);
    cursor: pointer;
    transition: 0.3s;
}

.drop-zone:hover {
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.02);
}

.drop-zone.drag-active {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.2);
    animation: pulse-border 1.5s infinite;
}

.upload-container {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    align-items: center;
    width: 100%;
    max-width: 900px;
    padding: 2rem;
}

.demo-grid {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    width: 100%;
}

.demo-card {
    background: rgba(255, 255, 255, 0.02);
    border: 2px dashed var(--border-color);
    border-radius: 1.5rem;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 260px;
}

.demo-card:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.05);
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.demo-preview-img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 0.75rem;
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    opacity: 0.8;
    transition: 0.3s;
}

.demo-card:hover .demo-preview-img {
    opacity: 1;
}

@keyframes pulse-border {
    0% {
        border-color: var(--accent-primary);
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }

    70% {
        border-color: var(--accent-hover);
        box-shadow: 0 0 0 15px rgba(99, 102, 241, 0);
    }

    100% {
        border-color: var(--accent-primary);
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

.bg-selector {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.bg-pill {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: 0.2s;
}

.bg-pill:hover {
    transform: scale(1.1);
    border-color: var(--accent-primary);
}

.bg-pill.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-primary);
}

.coord-tooltip {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.8);
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    font-family: monospace;
    pointer-events: none;
    border: 1px solid var(--border-color);
    z-index: 30;
    color: var(--warning);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* MODAL */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: #1e293b;
    padding: 2rem;
    border-radius: 1rem;
    width: 500px;
    max-width: 95%;
    max-height: 95vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    position: relative;
}

.data-preview {
    width: 100%;
    height: 150px;
    background: #0f172a;
    border: 1px solid var(--border-color);
    color: #10b981;
    padding: 0.75rem;
    font-family: monospace;
    font-size: 0.85rem;
    resize: none;
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

/* NEW STYLES */
.btn-green {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.5);
}

.btn-green:hover {
    background: rgba(16, 185, 129, 0.2);
}

.btn-green.active {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

.btn-red {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.5);
}

.btn-red:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-red.active {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

.btn-yellow {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.5);
}

.btn-yellow:hover {
    background: rgba(245, 158, 11, 0.2);
}

.btn-yellow.active {
    background: #f59e0b;
    color: white;
    border-color: #f59e0b;
}

.calibration-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.95);
    border: 2px solid var(--accent-primary);
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    z-index: 50;
    pointer-events: none;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s;
}

.calibration-hint h2 {
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

details summary {
    list-style: none;
    cursor: pointer;
    transition: color 0.2s;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary .lucide-chevron-down {
    transition: transform 0.2s ease;
    transform: rotate(-90deg);
    /* Points Right when collapsed */
}

details[open] summary .lucide-chevron-down {
    transform: rotate(0deg);
    /* Points Down when expanded */
}

/* TOAST NOTIFICATIONS */
.toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--accent-primary);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    font-size: 0.9rem;
    animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in 2.7s forwards;
    pointer-events: auto;
}

.toast-error {
    border-color: var(--danger);
}

.toast-success {
    border-color: var(--success);
}

@keyframes toast-in {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toast-out {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

.calibration-hint p {
    color: var(--text-dim);
    font-size: 1rem;
}

.sidebar-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.65rem;
    color: var(--text-dim);
    text-align: center;
    line-height: 1.4;
}

.sidebar-footer .made-by {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    color: var(--text-main);
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
}

.sidebar-footer .heart-icon {
    color: #ef4444;
    fill: #ef4444;
}

.sidebar-footer a {
    color: var(--accent-primary);
    text-decoration: none;
    word-break: break-all;
}

.sidebar-footer a:hover {
    text-decoration: underline;
}

/* GLOWING BUTTON ANIMATION */
@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
        border-color: var(--accent-primary);
    }

    50% {
        box-shadow: 0 0 20px 5px rgba(99, 102, 241, 0.4);
        border-color: #818cf8;
    }

    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
        border-color: var(--accent-primary);
    }
}

.btn-glow {
    animation: pulse-glow 2s infinite;
    border: 2px solid var(--accent-primary) !important;
    z-index: 1;
}

details summary {
    list-style: none;
    cursor: pointer;
}

details summary::-webkit-details-marker {
    display: none;
}

/* TOP STATUS BAR CSS */
.right-panel-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100vh;
    background: #000;
}

.top-status-bar {
    height: 48px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    flex-shrink: 0;
    z-index: 20;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

/* STATUS COLORS */
.status-digitize .status-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-digitize {
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.05);
}

.status-edit .status-dot {
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

.status-edit {
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(245, 158, 11, 0.05);
}

.status-delete .status-dot {
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

.status-delete {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

.status-calibrate .status-dot {
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

.status-calibrate {
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(245, 158, 11, 0.05);
}

.status-pick-color .status-dot {
    background: #ec4899;
    box-shadow: 0 0 8px #ec4899;
}

.status-pick-color {
    color: #ec4899;
    border-color: rgba(236, 72, 153, 0.3);
    background: rgba(236, 72, 153, 0.05);
}

.status-waiting .status-dot {
    background: var(--text-dim);
    box-shadow: none;
}

.status-waiting {
    color: var(--text-dim);
    border-color: var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

.status-stats {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-right: auto;
    margin-left: 2rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-value {
    color: var(--text-main);
    font-weight: 600;
    font-family: monospace;
    font-size: 0.85rem;
}

.stat-divider {
    width: 1px;
    height: 14px;
    background: var(--border-color);
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-dim);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border-color: var(--accent-primary);
}

.btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.confirm-bubble {
    position: absolute;
    top: 40px;
    right: 0;
    background: #1e293b;
    border: 1px solid var(--accent-primary);
    border-radius: 8px;
    padding: 8px 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: toast-in 0.2s ease-out;
}

.confirm-bubble::after {
    content: '';
    position: absolute;
    top: -6px;
    right: 12px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--accent-primary);
}

.confirm-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
}

.confirm-actions {
    display: flex;
    gap: 6px;
}

.btn-mini {
    padding: 4px 8px;
    font-size: 0.7rem;
    height: auto;
    border-radius: 4px;
}

/* AI EXTRACTION BAR */
.ai-extraction-bar {
    height: 54px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
    flex-shrink: 0;
    z-index: 19;
    overflow-x: auto;
    scrollbar-width: none;
    /* Hide scrollbar but allow scrolling */
}

.ai-extraction-bar::-webkit-scrollbar {
    display: none;
}

.ai-extraction-bar .btn {
    width: auto;
    height: 32px;
    padding: 0 0.75rem;
    font-size: 0.8rem;
    margin: 0;
}

.ai-extraction-bar input[type="range"] {
    width: 80px;
    margin: 0;
}

.ai-extraction-bar label {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin: 0;
}

.btn-copy-sample.copied {
    background: var(--success) !important;
    color: white !important;
    border-color: var(--success) !important;
}