/* ==================== */
/* VARIABLES & BASE */
/* ==================== */
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap');

:root {
    --panel-w: 320px;
    --bg: #f6f6f6;
    --ink: #000000;
    --muted: #6c6f75;
    --line: #e6e6e6;
    --accent: #000000;
    --accent-ink: #fff;
    --radius: 0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    color: var(--ink);
    background: #fff;
    font: 10.75px/1.75 "Space Mono", monospace;
    letter-spacing: 0.35px;
    display: flex;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ==================== */
/* LEFT PANEL */
/* ==================== */
.control-panel {
    z-index: 999;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 5px 5px 5px 15px;
    position: fixed;
    top: 0;
    left: 0;
    width: var(--panel-w);
    background: var(--bg);
}

.control-panel::-webkit-scrollbar {
    display: none;
}

.site-title {
    margin: 0;
    padding: 5px 5px;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px dotted var(--line);
}

.site-title pre {
    font-family: 'Space Mono', 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.15;
    color: var(--accent);
    margin: 0;
    text-align: left;
    display: inline-block;
    white-space: pre;
    overflow: visible;
}

.control-panel h1 {
    font-size: 11px;
    margin-bottom: 0;
    text-align: center;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
    padding: 0;
}

.control-panel h2 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #ffffff;
    margin: 0;
    font-weight: 700;
}

/* ==================== */
/* BLOCKS & SECTIONS */
/* ==================== */
.section {
    margin-bottom: 0;
    overflow: hidden;
}

.section:last-child {
    border-bottom: none;
}

.block {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px dotted var(--line);
    padding: 5px 5px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.block-title {
    text-transform: uppercase;
    font-weight: 700;
    color: #000000;
    font-size: 11px;
}

/* Section header */
.section-header {
    font-size: 11px;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #ffffff;
    margin: 10px;
    padding: 8px 8px 8px 15px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    background-color: #000000;
    backdrop-filter: blur(20px);
    border-bottom: 1px dotted var(--line);
    position: relative;
    transition: background 0.2s ease;
}

.section-header:hover {
    background: #999999;
    color: black;
}

.section-header::after {
    content: '➸';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    transition: transform 0.3s ease;
    font-size: 12px;

}

.control-section.open .section-header::after {
    transform: translateY(-50%) rotate(90deg);
    color: #ffffff
}

/* Section content */
.section-content {
    max-height: 0;
    overflow: hidden;
    transition: none;
    padding: 0;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px dotted var(--line);
}

.control-section.open .section-content {
    max-height: none;
    padding: 10px 10px 15px;
}

/* File Input Styling */
.file-input-group {
    margin-bottom: 10px;
}

.import-buttons-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 5px;
}

.import-buttons-row .btn {
    margin-bottom: 0;
}

.file-names-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.file-name {
    display: block;
    margin-top: 0;
    font-size: 9px;
    color: var(--muted);
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==================== */
/* BUTTONS */
/* ==================== */
button {
    font-family: "Space Mono", monospace;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-size: 10.75px;
    font-weight: 400;
}

.btn {
    border: 0.5px solid var(--line);
    background: #C5C5C7;
    
    padding: 3px 6px;
    cursor: pointer;
    font: inherit;
    transition: all 0.15s;
    width: 100%;
    margin-bottom: 5px;
}

.btn:hover {
    background: #ffffff;
    border: 1px dotted var(--accent);
    color: #000;
}

.btn-primary {
    width: 100%;
    padding: 6px 10px;
    background: #C5C5C7;
    color: #000000;
    border: 0.5px solid var(--line);
    margin-bottom: 5px;
}

.btn-primary:hover {
    background: #ffffff;
    border: 1px dotted var(--accent);
    color: #000;
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    width: 100%;
    padding: 6px 10px;
    background: transparent;
    border: 0.5px solid var(--line);
    color: var(--ink);
    margin-top: 5px;
}

.btn-secondary:hover {
    background: #e6e6e6;
}

.btn-success {
    width: 100%;
    padding: 6px 10px;
    background: #C5C5C7;
    color: #000000;
    border: 0.5px solid var(--line);
    margin-bottom: 5px;
}

.btn-success:hover {
    background: #ffffff;
    border: 1px dotted var(--accent);
    color: #000;
}

.btn-warning {
    width: 100%;
    padding: 6px 10px;
    background: #C5C5C7;
    color: #000000;
    border: 0.5px solid var(--line);
    margin-bottom: 5px;
}

.btn-warning:hover {
    background: #ffffff;
    border: 1px dotted #000;
    color: #000;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ==================== */
/* CONTROLS */
/* ==================== */
.control-group {
    margin-bottom: 10px;
    display: grid;
    grid-template-columns: 120px 1fr;
    align-items: center;
    gap: 8px;
    position: relative;
}

.control-group > label:first-child {
    display: block;
    margin-bottom: 0;
    font-size: 10.75px;
    color: var(--ink);
    text-transform: none;
    letter-spacing: 0.35px;
    text-align: left;
}

.slider-container {
    position: relative;
    display: block;
    width: 100%;
    height: 20px;
    overflow: visible;
}

/* ==================== */
/* RANGE SLIDERS */
/* ==================== */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    margin: 0;
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    z-index: 1;
    cursor: ew-resize;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 1px;
    background: repeating-linear-gradient(
        to right,
        black 0px,
        black 2px,
        transparent 3px,
        transparent 4px
    );
    border-radius: 1px;
}

input[type="range"]::-moz-range-track {
    height: 1px;
    background: repeating-linear-gradient(
        to right,
        black 0px,
        black 2px,
        transparent 3px,
        transparent 4px
    );
    border-radius: 1px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    background: transparent;
    cursor: default;
    margin-top: -9px;
    width: 100%;
    height: 20px;
    border: none;
}

input[type="range"]::-moz-range-thumb {
    background: transparent;
    border: none;
    cursor: ew-resize;
    width: 100%;
    height: 20px;
}

.number-span {
    cursor: text;
    white-space: nowrap;
    background: var(--bg);
    padding: 0 4px;
    position: relative;
    z-index: 2;
    pointer-events: auto;
}

.number-span.hovering {
    animation: blink 0.8s step-start infinite;
}

.number-span.blinking {
    animation: blink 0.8s step-start infinite;
}

@keyframes blink {
    50% {
        opacity: 0.3;
    }
}

[contenteditable="true"]:focus {
    outline: none;
}

input[type="number"] {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 55px;
    padding: 4px 6px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 0;
    color: var(--ink);
    font-size: 10.75px;
    font-family: "Space Mono", monospace;
    font-weight: 400;
    text-align: center;
    z-index: 3;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

input[type="text"] {
    width: 100%;
    padding: 4px 6px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 0;
    color: var(--ink);
    font-size: 10.75px;
    font-family: "Space Mono", monospace;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

input[type="file"] {
    display: none;
}

select {
    width: 100%;
    padding: 3px 6px;
    background: #C5C5C7;
    border: none;
    border-radius: 0;
    color: var(--ink);
    font-size: 10.75px;
    font-family: "Space Mono", monospace;
    cursor: pointer;
}

select:focus {
    outline: none;
}

/* Case à cocher */
.control-group label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    grid-column: 1 / -1;
}

/* ==================== */
/* CHECKBOXES */
/* ==================== */
input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 12.5px;
    height: 12.5px;
    border: 1px solid #000;
    background: #fff;
    cursor: pointer;
    display: inline-block;
    position: relative;
}

input[type="checkbox"]:checked {
    background: #000;
}

input[type="checkbox"]:disabled {
    opacity: 0.15;
    cursor: not-allowed;
}

/* ==================== */
/* COLOR SWATCH */
/* ==================== */
.color-swatch {
    width: 12.5px !important;
    height: 12.5px !important;
    cursor: pointer;
    display: inline-block;
    vertical-align: middle;
    border: 1px solid #000;
}

input[type="color"] {
    width: 100%;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 0;
    cursor: pointer;
    background: transparent;
    transition: all 0.15s ease;
}

input[type="color"]:hover {
    border-color: var(--accent);
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 0;
}

/* ==================== */
/* CANVAS AREA */
/* ==================== */
.canvas-area {
    flex: 1;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: #fff;
    margin-left: var(--panel-w);
    cursor: grab;
}

.canvas-area.panning {
    cursor: grabbing;
}

/* Canvas Placeholder */
.canvas-placeholder {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.canvas-placeholder.hidden {
    display: none;
}

.placeholder-content {
    text-align: center;
    opacity: 0.5;
}

.placeholder-content h2 {
    font-size: 18px;
    margin-bottom: 10px;
    font-weight: 700;
    color: var(--ink);
}

.placeholder-content p {
    font-size: 10.75px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.35px;
}

#preview-container {
    position: relative;
    background-color: white;
    box-shadow: 0 0 0 1px #e6e6e6;
    transform-origin: center center;
    transition: transform 0.1s ease-out;
}

#preview-canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0.3;
    pointer-events: none;
    z-index: 1;
}

#preview-svg {
    display: block;
    position: relative;
    z-index: 2;
}

/* Zoom Controls */
.zoom-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    padding: 5px;
    border-radius: 0;
    border: 1px dotted var(--line);
    box-shadow: none;
    z-index: 100;
}

.zoom-btn {
    width: 28px;
    height: 28px;
    background: var(--accent);
    color: var(--accent-ink);
    border: 0.5px solid var(--line);
    border-radius: 0;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-family: "Space Mono", monospace;
}

.zoom-btn:hover {
    background: #ffffff;
    border: 1px dotted var(--accent);
    color: #000;
}

.zoom-btn:active {
    transform: translateY(0);
}

#zoom-level {
    font-size: 10.75px;
    color: var(--ink);
    min-width: 45px;
    text-align: center;
    font-weight: 400;
    font-family: "Space Mono", monospace;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(246, 246, 246, 0.95);
    color: var(--ink);
    padding: 20px 40px;
    border-radius: 0;
    font-size: 10.75px;
    text-transform: uppercase;
    letter-spacing: 0.35px;
    z-index: 1000;
    border: 1px dotted var(--line);
}

/* ============================
    Animations
    ============================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    animation: fadeIn 0.3s ease;
}

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

.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ==================== */
/* SVG SHAPE LIST */
/* ==================== */
.svg-shape-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    padding: 0;
    border-radius: 0;
    border: none;
    max-height: 300px;
    overflow-y: auto;
    min-height: 80px;
}

.svg-shape-list .empty-message {
    text-align: center;
    color: var(--muted);
    font-size: 10.75px;
    padding: 20px;
    text-transform: none;
    letter-spacing: 0.35px;
}

.svg-shape-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 6px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px dotted var(--line);
    border-radius: 0;
    cursor: grab;
    transition: all 0.15s;
    user-select: none;
}

.svg-shape-item:active {
    cursor: grabbing;
}

.svg-shape-item:hover {
    background: #e6e6e6;
}

.svg-shape-item.dragging {
    opacity: 0.5;
}

.svg-shape-item.drag-over {
    border-top: 2px solid var(--accent);
}

.svg-shape-preview {
    width: 28px;
    height: 28px;
    background: white;
    border-radius: 0;
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.svg-shape-preview svg {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.svg-shape-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.svg-shape-name {
    font-size: 10.75px;
    color: var(--ink);
    font-weight: 700;
}

.svg-shape-index {
    font-size: 9px;
    color: var(--muted);
}

.svg-shape-actions {
    display: flex;
    gap: 4px;
}

.svg-shape-delete {
    background: transparent;
    border: none;
    color: var(--ink);
    padding: 0;
    border-radius: 0;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
}

.svg-shape-delete:hover {
    color: #ff4444;
    background: transparent;
}

.svg-shape-handle {
    font-size: 14px;
    color: var(--muted);
    cursor: grab;
    padding: 0;
}

.svg-shape-handle:active {
    cursor: grabbing;
}
