@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
    /* Couleurs principales - Gris et Bleu foncé */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1e293b;
    --bg-hover: #1f2937;

    /* Couleurs d'accent - Bleu */
    --accent-primary: #3b82f6;
    --accent-secondary: #60a5fa;
    --accent-hover: #2563eb;
    --accent-muted: rgba(59, 130, 246, 0.1);

    /* Couleurs neutres */
    --text-primary: #ffffff;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    /* Bordures */
    --border-color: #334155;
    --border-light: rgba(255, 255, 255, 0.1);
    --border-accent: #3b82f6;

    /* Rouge pour la poubelle uniquement */
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;

    /* Ombres légères */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: rgba(0, 0, 0, 0.4);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    backdrop-filter: blur(12px);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Buttons - Style minimaliste */
.btn {
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: -0.01em;
    font-family: inherit;
}

.btn:hover {
    transform: none;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-sm);
}

.btn-success {
    background: #0891b2;
    color: white;
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-success:hover {
    background: #0e7490;
}

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

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

.btn-danger {
    background: var(--danger-color);
    color: white;
    border-color: rgba(255, 255, 255, 0.1);
}

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

.btn-warning {
    background: #0891b2;
    color: white;
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-warning:hover {
    background: #0e7490;
}

.btn.disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Level Toggle Buttons */
.level-toggle-buttons {
    position: absolute;
    top: 80px;
    right: 20px;
    display: flex;
    gap: 0.5rem;
    z-index: 100;
}

.level-btn {
    width: 48px;
    height: 48px;
    border: 1px solid var(--border-light);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(8px);
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

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

.modal-content {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    max-width: 900px;
    max-height: 85vh;
    width: 90%;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-content h2 {
    margin-bottom: 1rem;
    text-align: center;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.close-map-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
    z-index: 1001;
    transition: all 0.15s ease;
    line-height: 1;
}

.close-map-modal:hover {
    color: var(--text-primary);
}

/* Map Selection Grid */
.map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.875rem;
    overflow-y: auto;
    max-height: calc(85vh - 120px);
    padding-right: 0.5rem;
}

.map-card {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.map-card:hover {
    border-color: var(--border-accent);
    background: var(--bg-hover);
}

.map-card-content {
    position: relative;
    width: 100%;
    height: 120px;
    margin-bottom: 0.5rem;
    overflow: hidden;
    border-radius: 6px;
}

.map-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.map-card:hover .map-thumb {
    transform: scale(1.02);
}

.map-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    object-fit: contain;
    transition: transform 0.2s ease;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.map-card:hover .map-icon {
    transform: translate(-50%, -50%) scale(1.05);
}

.map-card h3 {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: -0.01em;
}

/* Workspace */
.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Toolbar */
.toolbar {
    width: 300px;
    background: rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    padding-bottom: 5rem;
    overflow-y: auto;
    border-right: 1px solid var(--border-light);
    position: relative;
}

.toolbar-section {
    margin-bottom: 2rem;
}

.toolbar-section h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* Dragable Items Container */
.dragable-category {
    margin-bottom: 1.5rem;
}

.dragable-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.dragable-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Utility Items */
.utility-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.utility-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem;
    border-radius: 8px;
    text-align: center;
    cursor: grab;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}

.utility-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-accent);
}

.utility-item:active {
    cursor: grabbing;
}

.utility-item.disabled {
    opacity: 0.3;
    cursor: not-allowed !important;
    pointer-events: none;
}

.utility-icon {
    margin-bottom: 0.25rem;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 28px;
}

.utility-icon img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.utility-item span {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
}

/* Player Items */
.player-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.player-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem;
    border-radius: 8px;
    text-align: center;
    cursor: grab;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}

.player-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-accent);
}

.player-item:active {
    cursor: grabbing;
}

.player-item.disabled {
    opacity: 0.3;
    cursor: not-allowed !important;
    pointer-events: none;
}

.player-icon {
    margin-bottom: 0.25rem;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 28px;
}

.player-icon img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.player-item span {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
}

/* Drawing Tools */
.drawing-tools {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
}

.tool-btn {
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.9rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-light);
}

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

.tool-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed !important;
    pointer-events: none;
}

.tool-btn img {
    width: 22px;
    height: 22px;
    display: block;
    margin: 0 auto;
    filter: brightness(0) invert(1);
}

label.tool-btn {
    margin: 0;
}

/* Color Picker */
.color-picker {
    margin-top: 1rem;
}

.color-picker label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.color-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.color-btn {
    width: 36px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.color-btn:hover {
    transform: scale(1.05);
    border-color: var(--border-light);
}

.color-btn.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

/* Brush Size */
.brush-size {
    margin-top: 1rem;
}

.brush-size label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.brush-size input[type="range"] {
    width: 100%;
    cursor: pointer;
}

/* Floating Reset Zoom Button */
.floating-reset-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    padding: 0.625rem 1rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    letter-spacing: -0.01em;
}

.floating-reset-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.floating-reset-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* Toolbar Help Button */
.toolbar-help-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.toolbar-help-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-accent);
}

.toolbar-help-btn.active {
    background: var(--accent-muted);
    border-color: var(--border-accent);
}

.toolbar-help-btn img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}

/* Help Panel */
.help-panel {
    position: absolute;
    top: 55px;
    right: 15px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 1rem;
    min-width: 250px;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 15;
}

.help-panel.show {
    display: block;
    animation: slideDown 0.2s ease;
}

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

.help-panel h4 {
    color: var(--text-primary);
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.help-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

.help-key {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    white-space: nowrap;
}

.help-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
}

/* Toolbar Trash Button - ROUGE UNIQUEMENT ICI */
.toolbar-trash-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: var(--danger-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-trash-btn:hover {
    background: var(--danger-hover);
}

.toolbar-trash-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed !important;
    pointer-events: none;
}

.toolbar-trash-btn img {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    padding: 0;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

#canvasWrapper {
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#stratCanvas {
    display: block;
}

/* Image Modal */
.image-modal .modal-content {
    max-width: 90vw;
    max-height: 90vh;
    padding: 0;
    position: relative;
    background: transparent;
    border: none;
}

.image-modal-content {
    display: flex;
    justify-content: center;
    align-items: center;
}

.close-modal {
    position: absolute;
    top: -40px;
    right: 0;
    font-size: 2.5rem;
    color: var(--text-muted);
    cursor: pointer;
    z-index: 1001;
    transition: all 0.15s ease;
}

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

#zoomedImage {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Mobile Warning Overlay */
.mobile-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.98);
    z-index: 10000;
    overflow: hidden;
}

.mobile-warning.show {
    display: block;
}

.mobile-warning-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 1.5rem 1.25rem;
    max-width: 90vw;
    width: auto;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.2s ease;
}

.mobile-warning-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    line-height: 1;
}

.mobile-warning-content h2 {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.mobile-warning-content p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.mobile-warning-content p:last-child {
    margin-bottom: 0;
}

/* Responsive adjustments for very small screens */
@media (max-width: 400px) {
    .mobile-warning-content {
        padding: 1.25rem 1rem;
    }

    .mobile-warning-icon {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }

    .mobile-warning-content h2 {
        font-size: 1.125rem;
        margin-bottom: 0.5rem;
    }

    .mobile-warning-content p {
        font-size: 0.8125rem;
    }
}

@media (max-width: 350px) {
    .mobile-warning-content {
        padding: 1rem 0.75rem;
    }

    .mobile-warning-icon {
        font-size: 2rem;
    }

    .mobile-warning-content h2 {
        font-size: 1rem;
    }

    .mobile-warning-content p {
        font-size: 0.75rem;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .toolbar {
        width: 220px;
    }

    .utility-items {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .workspace {
        flex-direction: column;
    }

    .toolbar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        max-height: 40vh;
    }

    .canvas-container {
        padding: 0;
    }
}
