* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    touch-action: pan-x pan-y;
    overscroll-behavior: none;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 20px 30px;
    transition: all 0.3s ease;
}

.header.hidden {
    transform: translateY(-100%);
    position: absolute;
    width: 100%;
    z-index: -1;
}

.header h1 {
    margin-bottom: 15px;
    font-size: 28px;
}

.header-controls {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 600;
    font-size: 14px;
}

.control-group select,
.control-group input[type="number"] {
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    background: white;
}

.door-counter {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: 600;
}

.door-counter.warning {
    background: #e74c3c;
    animation: pulse 0.5s;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.btn-warning {
    background: #e74c3c;
    color: white;
}

.btn-warning:hover {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}

.btn-success {
    background: #27ae60;
    color: white;
    width: 100%;
    margin-top: 10px;
}

.btn-success:hover {
    background: #229954;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(149, 165, 166, 0.4);
}

#symmetryControl {
    align-items: center;
}

#symmetryControl label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-weight: 600;
}

#symmetryControl input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.share-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 8px;
}

.share-controls input[type="text"] {
    padding: 8px 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    width: 120px;
    text-align: center;
}

.share-code-display {
    background: rgba(46, 204, 113, 0.2);
    padding: 8px 15px;
    border-radius: 5px;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 3px;
    color: #27ae60;
    border: 2px solid #27ae60;
    min-width: 100px;
    text-align: center;
}

.share-code-display:empty {
    display: none;
}

.main-content {
    display: flex;
    min-height: calc(100vh - 200px);
    position: relative;
}

.main-content.header-hidden {
    min-height: 100vh;
}

.canvas-container {
    flex: 1;
    display: flex;
    background: #f8f9fa;
    padding: 20px;
    gap: 20px;
    position: relative;
}

.tool-panel {
    position: absolute;
    left: 20px;
    top: 20px;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 200px;
    height: fit-content;
    transition: all 0.3s ease;
    z-index: 10;
}

.tool-panel.hidden {
    transform: translateX(-240px);
}

.tool-panel h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 18px;
}

.tool-section {
    margin-bottom: 20px;
}

.tool-btn {
    display: block;
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    text-align: left;
}

.tool-btn:hover {
    background: #f8f9fa;
    border-color: #3498db;
}

.tool-btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.tool-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 13px;
}

.tool-section input[type="color"] {
    width: 100%;
    height: 40px;
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
}

.canvas-wrapper {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: white;
    overflow: hidden;
}

#gridCanvas {
    border: 2px solid #34495e;
    cursor: crosshair;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    touch-action: none;
    transform-origin: center center;
}

#gridCanvas.dragging {
    cursor: grabbing;
}

.sidebar {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 350px;
    background: #f8f9fa;
    padding: 20px;
    overflow-y: auto;
    border-left: 1px solid #ddd;
    transition: all 0.3s ease;
    z-index: 10;
}

.sidebar.hidden {
    transform: translateX(370px);
}

.objects-panel {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.objects-panel h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 20px;
}

.add-object-form {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.add-object-form h4 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 16px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
    font-size: 13px;
}

.form-group input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
}

.objects-list {
    max-height: 400px;
    overflow-y: auto;
}

.empty-message {
    text-align: center;
    color: #999;
    padding: 20px;
    font-style: italic;
}

.object-item {
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: grab;
    transition: all 0.3s;
    position: relative;
}

.object-item:hover {
    border-color: #3498db;
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.object-item.selected {
    border: 3px solid #3498db;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
    animation: pulse-selected 1.5s ease-in-out infinite;
    position: relative;
}

.object-item.selected::before {
    content: '📍 MODE PLACEMENT';
    position: absolute;
    top: -8px;
    right: -8px;
    background: #3498db;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

@keyframes pulse-selected {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
    }
    50% {
        box-shadow: 0 4px 25px rgba(52, 152, 219, 0.7);
    }
}

.object-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.object-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.object-title {
    font-weight: 700;
    font-size: 15px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.object-color-indicator {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid #ddd;
}

.object-delete {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: all 0.3s;
}

.object-delete:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.object-info {
    font-size: 13px;
    color: #666;
    display: flex;
    gap: 15px;
}

.object-limit-control {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 8px;
}

.object-limit-control label {
    font-size: 11px;
    color: #666;
    font-weight: 600;
}

.object-limit-control .limit-input {
    width: 60px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

.object-limit-control .limit-input:focus {
    outline: none;
    border-color: #3498db;
}

.instructions {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.instructions h4 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 16px;
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    padding: 8px 0;
    color: #555;
    font-size: 13px;
    line-height: 1.6;
}

.instructions strong {
    color: #2c3e50;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    min-width: 350px;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons .btn {
    flex: 1;
}

/* Drag Preview */
.drag-preview {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    border: 2px solid #333;
    border-radius: 5px;
    opacity: 0.8;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    font-size: 12px;
    transform: translate(-50%, -50%);
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #e74c3c;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
    z-index: 2000;
    font-weight: 600;
    animation: slideIn 0.3s ease-out;
    max-width: 300px;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification.success {
    background: #27ae60;
}

.notification.info {
    background: #3498db;
}

/* Contrôles de zoom */
.zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 100;
}

.zoom-btn {
    width: 40px;
    height: 40px;
    background: white;
    border: 2px solid #34495e;
    border-radius: 8px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
    color: #34495e;
}

.zoom-btn:hover {
    background: #3498db;
    color: white;
    border-color: #3498db;
    transform: scale(1.1);
}

.zoom-btn:active {
    transform: scale(0.95);
}

.canvas-wrapper {
    position: relative;
    flex: 1;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: auto;
}

/* Boutons de toggle des panneaux */
.toggle-panel-btn {
    position: fixed;
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 8px;
    cursor: pointer;
    z-index: 500;
    font-size: 16px;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
}

.toggle-panel-btn:hover {
    background: #2980b9;
    transform: scale(1.1);
}

.toggle-header {
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.toggle-header.rotated {
    transform: translateX(-50%) rotate(180deg);
}

/* Indication pan */
.pan-hint {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(52, 152, 219, 0.95);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 5;
    pointer-events: none;
    user-select: none;
}

.pan-hint strong {
    color: #FFD700;
    font-weight: 700;
}

/* Indication placement */
.placement-hint {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(46, 204, 113, 0.95);
    color: white;
    padding: 12px 25px;
    border-radius: 25px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 5;
    pointer-events: none;
    user-select: none;
    animation: slide-down 0.3s ease-out;
}

.placement-hint strong {
    color: #FFD700;
    font-weight: 700;
}

@keyframes slide-down {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.toggle-left {
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.toggle-left.rotated {
    transform: translateY(-50%) rotate(180deg);
}

.toggle-right {
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

.toggle-right.rotated {
    transform: translateY(-50%) rotate(180deg);
}

/* Indicateur Firebase */
.firebase-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.firebase-status.connected {
    background: rgba(46, 204, 113, 0.3);
    color: #2ecc71;
}

.firebase-status.offline {
    background: rgba(241, 196, 15, 0.3);
    color: #f1c40f;
}

.firebase-status.local {
    background: rgba(52, 152, 219, 0.3);
    color: #3498db;
}

.firebase-status.error {
    background: rgba(231, 76, 60, 0.3);
    color: #e74c3c;
}

.firebase-status.syncing {
    animation: pulse-sync 1.5s ease-in-out infinite;
}

@keyframes pulse-sync {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.02); }
}

/* Affichage code de session actif */
.share-code-display {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 14px;
    letter-spacing: 2px;
}

.share-code-display.active-session {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    padding: 6px 14px;
    border-radius: 8px;
    color: white;
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.4);
}

/* Contrôles de partage */
.share-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.share-controls input[type="text"] {
    width: 80px;
    text-align: center;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    letter-spacing: 2px;
}

.share-controls input[type="text"]:disabled {
    background: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 1400px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 90%;
        max-width: 400px;
        border-left: none;
        border-top: 1px solid #ddd;
    }
    
    .sidebar.hidden {
        transform: translateX(100%);
    }
}
