.file-upload-section {
    background: #f8f8f8;
    padding: 15px;
    border-radius: 4px;
    margin: 15px 0;
    border: 1px solid #ddd;
    width: 100%;
    box-sizing: border-box;
    display: none !important;
}

.file-upload-section { display:block !important; margin-top:10px; }
.file-upload-group { display:flex !important; align-items:center; gap:10px; flex-wrap:wrap; margin:6px 0; }
.file-upload-group img { max-width:100%; height:auto; }
#fileInput, #launchIaBtn { display:inline-block !important; }

.file-upload-group {
    margin-bottom: 12px;
}

.file-upload-group:last-child {
    margin-bottom: 0;
}

.file-upload-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #444;
    text-align: left;
    min-width: auto;
}

.file-upload-group input[type="file"] {
    width: 100%;
    padding: 5px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.canvas-container {
    position: relative;
    margin: 20px 0;
    overflow: hidden;
    border: 1px solid #ccc;
    cursor: grab;
    image-rendering: auto;
    image-rendering: optimizeQuality;
    -ms-interpolation-mode: bicubic;
    transition: background-color 0.3s ease;
}

.canvas-container.dragging {
    cursor: grabbing !important;
}

.canvas-container.zooming {
    cursor: zoom-in !important;
}

.canvas-container:active {
    cursor: grabbing;
}

canvas {
    display: block;
    image-rendering: auto;
    will-change: transform;
}

/* Contrôles et sliders */
.controls {
    margin: 20px 0;
    display: grid;
    gap: 10px;
    background: #f8f8f8;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
}

.icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
}

.icon svg {
    width: 100%;
    height: 100%;
    stroke: #555;
}

label {
    min-width: 110px;
    font-weight: bold;
    color: #444;
    font-size: 14px;
    text-align: right;
    flex-shrink: 0;
}

input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: #ddd;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: none;
    transition: width 0.05s linear, height 0.05s linear !important;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: none;
    transition: width 0.05s linear, height 0.05s linear !important;
}

.value-display {
    min-width: 50px;
    text-align: right;
    font-family: monospace;
    color: #333;
    font-size: 14px;
    flex-shrink: 0;
}

button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: background 0.2s;
}

button:hover {
    background: #45a049;
}

button.active {
    background: #f44336;
}

button.active:hover {
    background: #da190b;
}

/* FPS counter */
#fpsCounter {
    margin-left: auto;
    background: #333;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 10px;
    font-family: monospace;
    white-space: nowrap;
}

.rotation-icon {
    animation: spin 10s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Mode plein écran */
body.custom-fullscreen-mode {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: black !important;
}

.container.custom-fullscreen, 
.canvas-container.custom-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    z-index: 1000 !important;
    background-color: black !important;
    overflow: hidden !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    border: none !important;
}

.canvas-container.custom-fullscreen {
    transform: none !important;
}

.canvas-container.custom-fullscreen canvas {
    display: block !important;
    position: absolute !important;
    max-width: none !important;
    max-height: none !important;
    transform-origin: center center !important;
    will-change: transform !important;
    transition: none !important;
}

.container.custom-fullscreen h1,
.container.custom-fullscreen #debug {
    display: none !important;
}

/* Panneau flottant et contrôles */
.floating-controls-panel {
    position: fixed !important;
    left: 20px !important;
    top: 20px !important;
    background: rgba(255, 255, 255, 0.95) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
    z-index: 1000 !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    min-width: 150px;
    max-width: 450px;
    min-height: 200px;
    max-height: 80vh;
    overflow: hidden !important;
    box-sizing: border-box !important;
    transition: opacity 0.2s ease !important;
}

.floating-controls-panel.dragging {
    opacity: 0.8 !important;
}

.floating-controls-panel.resizing {
    opacity: 0.8 !important;
}

body.custom-fullscreen-mode .floating-controls-panel {
    border: 2px solid #4CAF50 !important;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5) !important;
    background: rgba(255, 255, 255, 0.97) !important;
    z-index: 2002 !important;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #4CAF50;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
    cursor: move;
    box-sizing: border-box !important;
    height: auto !important;
}

.panel-header * {
    cursor: move;
}

.header-title {
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.header-title::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='9' cy='12' r='1'%3E%3C/circle%3E%3Ccircle cx='15' cy='12' r='1'%3E%3C/circle%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.panel-content {
    padding: 10px !important;
    max-height: 500px !important;
    overflow: hidden !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

/* Boutons spéciaux */
.control-group.special-layout {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    margin-bottom: 15px;
    align-items: center;
}

.control-group.special-layout button {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
}

.control-group.special-layout button svg {
    width: 20px;
    height: 20px;
}

#fullscreenBtn, #exportBtn {
    background: #4c7caf;
}

#fullscreenBtn:hover, #exportBtn:hover {
    background: #3a5d8a;
}

/* Plein écran */
body.custom-fullscreen-mode #fullscreenBtn {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 2001 !important;
    background: #000000 !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    width: 40px !important;
    height: 40px !important;
}

body.custom-fullscreen-mode #fullscreenBtn:hover {
    background: #333333 !important;
}

body.custom-fullscreen-mode #fullscreenBtn svg {
    transform: rotate(180deg);
}

/* Bouton toggle */
.toggle-panel-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(76, 175, 80, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
}

.toggle-panel-btn svg {
    width: 24px;
    height: 24px;
    stroke: white;
}

body.custom-fullscreen-mode .toggle-panel-btn {
    display: flex !important;
    z-index: 2001 !important;
}

/* Indicateur de chargement */
.loading-indicator {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 10px;
}

.loading-text {
    font-size: 16px;
    margin-bottom: 5px;
}

.loading-progress {
    font-size: 14px;
    font-weight: bold;
}

/* Poignée de redimensionnement */
.resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 35%, rgba(76, 175, 80, 0.7) 35%, rgba(76, 175, 80, 0.8) 50%, rgba(76, 175, 80, 0.9) 65%, #4CAF50 80%);
    z-index: 1001;
    border-radius: 0 0 8px 0;
    transition: opacity 0.2s;
}

.resize-handle:hover {
    opacity: 1;
    background: linear-gradient(135deg, transparent 30%, rgba(76, 175, 80, 0.8) 30%, rgba(76, 175, 80, 0.9) 50%, #4CAF50 70%);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

/* Optimisation pour le panneau flottant */
.floating-controls-panel .controls {
    margin: 0 !important;
    padding: 5px !important;
    background: none !important;
    border: none !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
    width: 100% !important;
    gap: 3px !important;
}

.floating-controls-panel .control-group {
    margin-bottom: 4px !important;
    padding: 0 !important;
    gap: 4px !important;
    width: 100% !important;
}

.floating-controls-panel .icon {
    width: 18px !important;
    height: 18px !important;
}

.floating-controls-panel label {
    min-width: 35px !important;
    max-width: 50px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.floating-controls-panel input[type="range"] {
    min-width: 20px !important;
    height: 5px !important;
}

.floating-controls-panel input[type="range"]::-webkit-slider-thumb {
    width: 12px;
    height: 12px;
}

.floating-controls-panel input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
}

.floating-controls-panel .value-display {
    min-width: 35px !important;
    font-size: 11px !important;
}

/* Panneau à petite échelle */
.floating-controls-panel.small-scale .control-group {
    margin-bottom: 2px !important;
    gap: 2px !important;
}

.floating-controls-panel.small-scale .icon {
    width: 14px !important;
    height: 14px !important;
}

.floating-controls-panel.small-scale label,
.floating-controls-panel.small-scale .value-display {
    min-width: 25px !important;
    max-width: 35px !important;
    font-size: 9px !important;
}

.floating-controls-panel.small-scale input[type="range"] {
    min-width: 15px !important;
    height: 3px !important;
}

.floating-controls-panel.small-scale input[type="range"]::-webkit-slider-thumb,
.floating-controls-panel.small-scale input[type="range"]::-moz-range-thumb {
    width: 10px !important;
    height: 10px !important;
}

/* Curseurs */
body.resizing * {
    cursor: nwse-resize !important;
}
