:root {
    --bg-primary: #1e1f22;
    --bg-secondary: #2b2d30;
    --bg-tertiary: #313335;
    --border-color: #3c3f41;
    --accent-blue: #2bdbc3;
    --accent-green: #499c54;
    --text-primary: #bcbec4;
    --text-secondary: #868a91;
    --text-tertiary: #2b2d30;
    --grid-color: rgba(60, 63, 65, 0.4);
    --component-stroke: #bcbec4;
    --wire-color: #2bdbc3;
}

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

body {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}

#root {
    width: 100vw;
    height: 100vh;
}

.app-container {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 48px 1fr 32px;
    height: 100vh;
    gap: 0;
}

/* Header */
.header {
    grid-column: 1 / -1;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: relative;
    z-index: 2000;
}

.title {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.title .logo {
    width: 24px;
    height: 24px;
    vertical-align: middle;
    margin-right: 8px;
}

.title .version {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 4px;
}

.toolbar {
    display: flex;
    gap: 8px;
}

.btn-accueil {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 12px;
}

.btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    padding: 6px 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn:hover {
    background: var(--border-color);
}

.btn:active {
    background: var(--bg-tertiary);
}

.tool-sidebar {
    position: absolute;
    left: 16px;
    top: 68px;
    bottom: 52px;
    width: 56px;
    background: rgba(43, 45, 48, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 8px;
    z-index: 1100;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 20px;
    color: var(--text-secondary);
    position: relative;
}

.tool-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
    transform: scale(1.05);
}

.tool-btn.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

/* Tooltip au hover */
.tool-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 52px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
}

.tool-btn:hover::after {
    opacity: 1;
}

/* Divider entre les groupes d'outils */
.tool-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.sidebar.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-20px);
    transition: all 0.2s ease;
}

.sidebar {
    position: absolute;
    left: 88px;
    top: 68px;
    bottom: 52px;
    width: 260px;
    border-radius: 15px;
    background: rgba(43, 45, 48, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 16px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
}

.sidebar h3 {
    color: var(--text-secondary);
    font-size: 11px;
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
}

.component-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.component-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 8px;
    cursor: grab;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.component-btn:hover {
    background: var(--border-color);
    transform: translateX(2px);
}

.component-btn:active {
    cursor: grabbing;
}

.component-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.component-name {
    font-size: 12px;
    color: var(--text-primary);
}

/* Canvas - Prend maintenant toute la largeur */
.canvas-container {
    grid-column: 1;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.canvas {
    position: relative;
    width: 100%;
    height: 100%;
}

.canvas-container.wire-mode .component-instance {
    pointer-events: none !important;
}

/* Mais l'aperçu reste visible normalement */
.canvas-container.wire-mode .wire-preview {
    pointer-events: none;
}

.component-instance {
    position: absolute;
    cursor: move;
    user-select: none;
}

.component-instance:hover {
    opacity: 0.8;
}

.component-instance.selected {
    outline: 2px solid var(--accent-blue);
    border-radius: 5px;
    outline-offset: 4px;
}

.canvas-container.select-mode {
    cursor: default;
}

.canvas-container.select-mode .component-instance {
    cursor: move;
}

.canvas-container.place-mode {
    cursor: crosshair;
}

.canvas-container.wire-mode {
    cursor: crosshair;
}

.canvas-container.wire-mode .component-instance {
    pointer-events: none !important;
}

.wire {
    stroke: var(--wire-color);
    stroke-width: 2;
    fill: none;
    transition: stroke-width 0.15s ease;
}

.wire:hover {
    stroke-width: 4;
}

.wire.selected {
    stroke: #ff6b6b; /* Rouge pour indiquer la sélection */
    stroke-width: 4;
    filter: drop-shadow(0 0 4px rgba(255, 107, 107, 0.6));
}

.wire-preview {
    stroke: var(--accent-blue);
    stroke-width: 2;
    stroke-dasharray: 5, 5;
    fill: none;
    opacity: 0.5;
}

/* Footer */
.footer {
    grid-column: 1 / -1;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 11px;
    color: var(--text-secondary);
    position: relative;
    z-index: 2000;
}

.mode-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mode-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-green);
}

/* Delete button */
.delete-btn {
    position: absolute;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    z-index: 10000;
    transition: background 0.15s ease;
}

.delete-btn:hover {
    background: #c75450;
    color: white;
    border-color: #c75450;
}

/* Scrollbar pour la sidebar */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Input de recherche dans la sidebar */
.sidebar input[type="text"] {
    border-radius: 8px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Modal container */
.modal-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 700px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Modal header */
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-logo img {
    width: 40px;
    height: 40px;
}

.modal-title-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-version {
    font-size: 12px;
    color: var(--text-secondary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Navigation */
.modal-nav {
    display: flex;
    gap: 4px;
    padding: 8px 16px 0 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.modal-nav-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    transition: all 0.15s ease;
    position: relative;
}

.modal-nav-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.modal-nav-btn.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

/* Modal body */
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Patchnotes container */
.patchnotes-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Patch item */
.patch-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transition: all 0.2s ease;
}

.patch-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--accent-blue), var(--accent-green));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.patch-item:hover::before {
    opacity: 1;
}

/* Patch header */
.patch-header {
    padding: 16px 20px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.patch-header:hover {
    background: var(--border-color);
}

.patch-header.expanded {
    background: var(--bg-primary);
}

.patch-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.patch-version {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-blue);
}

.patch-date {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
}

.patch-header i {
    color: var(--text-secondary);
    font-size: 20px;
    transition: transform 0.2s ease;
}

/* Patch content */
.patch-content {
    padding: 20px;
    animation: expandDown 0.2s ease;
    border-top: 1px solid var(--border-color);
}

@keyframes expandDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.patch-section {
    margin-bottom: 20px;
}

.patch-section:last-child {
    margin-bottom: 0;
}

.patch-section h4 {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.patch-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.patch-section li {
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.6;
    padding-left: 20px;
    position: relative;
}

.patch-section li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--accent-blue);
    font-size: 12px;
}

/* Credits container */
.credits-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.credit-section {
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border-left: 3px solid var(--accent-blue);
}

.credit-section h3 {
    color: var(--accent-blue);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.credit-item {
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.8;
    margin: 0;
}

.credit-item strong {
    color: var(--accent-blue);
    font-weight: 600;
}

.tech-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.tech-list li {
    color: var(--text-primary);
    font-size: 13px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 4px;
    border-left: 2px solid var(--accent-green);
}

.credit-footer {
    text-align: center;
    padding: 16px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.8;
}

/* Scrollbar */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.welcome-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    max-width: 500px;
    text-align: center;
    animation: slideUp 0.3s ease;
}

.welcome-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.welcome-header img {
    width: 60px;
    height: 60px;
}

.welcome-header h2 {
    color: var(--text-primary);
    font-size: 24px;
    margin: 0;
}

.welcome-content {
    margin-bottom: 32px;
}

.welcome-content p {
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    margin: 8px 0;
}

.welcome-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-primary:hover {
    background: #3a8eef;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.welcome-footer {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.welcome-footer label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
}

/* Tutorial overlay */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9998;
    animation: fadeIn 0.3s ease;
}

.tutorial-spotlight {
    border: 3px solid var(--accent-blue);
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
    z-index: 9999;
    pointer-events: none;
    transition: all 0.3s ease;
}

/* Tutorial card */
.tutorial-card {
    background: var(--bg-secondary);
    border: 2px solid var(--accent-blue);
    border-radius: 12px;
    padding: 24px;
    width: 400px;
    max-width: 90vw;
    z-index: 10000;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.tutorial-step {
    color: var(--accent-blue);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tutorial-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.tutorial-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tutorial-card h3 {
    color: var(--text-primary);
    font-size: 18px;
    margin: 0 0 12px 0;
}

.tutorial-card p {
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 20px 0;
}

/* Tutorial progress */
.tutorial-progress {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
}

.tutorial-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    transition: all 0.2s ease;
}

.tutorial-dot.active {
    background: var(--accent-blue);
    width: 24px;
    border-radius: 4px;
}

.tutorial-dot.completed {
    background: var(--accent-green);
}

/* Tutorial actions */
.tutorial-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.tutorial-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 18px;
    margin: 0 0 12px 0;
}

.tutorial-title i {
    color: var(--accent-blue);
    font-size: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    transition: all 0.15s ease;
}

.btn:hover {
    background: var(--border-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

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