/* ============================================
   AP Annotator - Sprint 5 Corrections
   Correctifs affichage + nouvelles fonctionnalités
   Date : 27 janvier 2026
   ============================================ */

/* ========== CORRECTION: AFFICHAGE MOBILE ========== */

/* Actions buttons - TOUJOURS visibles sur mobile */
@media (max-width: 768px) {
    .actions {
        display: flex !important;
        flex-direction: column;
        gap: 8px;
        width: 100%;
        padding: 12px;
    }
    
    .actions button {
        width: 100%;
        justify-content: center;
        font-size: 14px;
        padding: 12px 16px;
        min-height: 48px;
    }
    
    .actions button span {
        display: inline !important; /* Force affichage texte */
    }
    
    /* Section Actions - Scroll horizontal si besoin */
    .actions-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ========== CORRECTION: EXPORTS ACCESSIBLES ========== */
@media (max-width: 768px) {
    /* Groupe Export buttons */
    .export-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
        margin-bottom: 12px;
    }
    
    #btnExportHQ,
    #btnExportMQ,
    #btnExportLQ {
        display: flex !important;
        width: 100%;
        justify-content: center;
    }
    
    /* Menu Export déroulant (alternative) */
    .export-dropdown {
        position: relative;
    }
    
    .export-dropdown-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        box-shadow: var(--shadow-lg);
        z-index: 1000;
        margin-top: 4px;
    }
    
    .export-dropdown-menu.open {
        display: block;
    }
    
    .export-dropdown-item {
        padding: 12px 16px;
        border-bottom: 1px solid var(--border-color);
        cursor: pointer;
        transition: background 0.2s;
    }
    
    .export-dropdown-item:last-child {
        border-bottom: none;
    }
    
    .export-dropdown-item:hover {
        background: var(--bg-tertiary);
    }
}

/* ========== NOUVELLE FONCTIONNALITÉ: CONTRÔLE TAILLE TEXTE ========== */

/* Container pour contrôle taille texte */
.text-size-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 12px;
}

.text-size-control label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-size-control input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
}

.text-size-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--cyan-cedit);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.text-size-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--cyan-cedit);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.text-size-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--cyan-cedit);
    text-align: center;
    min-width: 50px;
}

/* Bouton presets taille texte */
.text-size-presets {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.text-size-preset-btn {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.text-size-preset-btn:hover {
    background: var(--cyan-cedit);
    color: white;
    border-color: var(--cyan-cedit);
}

.text-size-preset-btn.active {
    background: var(--cyan-cedit);
    color: white;
    border-color: var(--cyan-cedit);
}

/* ========== NOUVELLE FONCTIONNALITÉ: RECADRAGE IMAGE ========== */

/* Bouton Crop */
#btnCrop {
    background: linear-gradient(135deg, #FF5A5F 0%, #FF3D43 100%);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

#btnCrop:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 90, 95, 0.4);
}

#btnCrop.active {
    background: linear-gradient(135deg, #00ED64 0%, #00C850 100%);
}

/* Modal Crop */
.crop-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.crop-modal.open {
    display: flex;
}

.crop-container {
    position: relative;
    max-width: 90vw;
    max-height: 80vh;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-xl);
}

.crop-canvas-wrapper {
    position: relative;
    overflow: hidden;
    border: 2px solid var(--cyan-cedit);
    border-radius: 8px;
    margin-bottom: 16px;
}

.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.crop-selection {
    position: absolute;
    border: 2px dashed var(--cyan-cedit);
    background: rgba(0, 198, 255, 0.1);
    cursor: move;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--cyan-cedit);
    border-radius: 50%;
    cursor: pointer;
}

.crop-handle.nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle.ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle.sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle.se { bottom: -6px; right: -6px; cursor: se-resize; }

.crop-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.crop-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.crop-btn-apply {
    background: var(--green-cedit);
    color: white;
}

.crop-btn-apply:hover {
    background: #00D658;
    transform: scale(1.05);
}

.crop-btn-cancel {
    background: var(--pink-cedit);
    color: white;
}

.crop-btn-cancel:hover {
    background: #FF4A4F;
    transform: scale(1.05);
}

.crop-btn-reset {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.crop-btn-reset:hover {
    background: var(--bg-secondary);
}

/* Aspect Ratio presets */
.crop-ratio-presets {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.crop-ratio-btn {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.crop-ratio-btn:hover {
    background: var(--cyan-cedit);
    color: white;
    border-color: var(--cyan-cedit);
}

.crop-ratio-btn.active {
    background: var(--cyan-cedit);
    color: white;
    border-color: var(--cyan-cedit);
}

/* ========== CORRECTION: ESPACEMENTS INTERFACE ========== */

/* Plus d'espace entre les sections */
.section-spacing {
    margin-bottom: 20px;
}

/* Meilleure lisibilité des labels */
label {
    line-height: 1.5;
    margin-bottom: 8px;
}

/* Padding des panels */
.panel {
    padding: 16px;
}

@media (max-width: 768px) {
    .panel {
        padding: 12px;
    }
}

/* ========== CORRECTION: TOOLBAR RESPONSIVE ========== */

@media (max-width: 768px) {
    /* Toolbar items wrap better */
    .toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .toolbar > div {
        flex-shrink: 1;
        min-width: auto;
    }
    
    /* Labels cachés sur petit écran */
    .toolbar span.text-sm {
        display: none;
    }
    
    /* Borders entre groupes */
    .toolbar .border-r {
        border-right: none;
        padding-right: 0;
    }
}

/* ========== AMÉLIORATION: ZOOM CONTROLS ========== */

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 16px;
}

@media (max-width: 768px) {
    .zoom-controls {
        position: fixed;
        bottom: 80px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 900;
        box-shadow: var(--shadow-xl);
    }
}

/* ========== AMÉLIORATION: CANVAS CONTAINER ========== */

#canvasContainer {
    position: relative;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    min-height: 400px;
}

@media (max-width: 768px) {
    #canvasContainer {
        min-height: 300px;
        height: calc(100vh - 280px);
    }
}

/* ========== AMÉLIORATION: RESPONSIVE GRID ========== */

@media (max-width: 768px) {
    .grid-cols-12 {
        grid-template-columns: 1fr;
    }
    
    .col-span-3,
    .col-span-9 {
        grid-column: span 1;
    }
}

/* ========== ACCESSIBILITÉ ========== */

/* Focus visible pour keyboard navigation */
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--cyan-cedit);
    outline-offset: 2px;
}

/* Indicateur loading */
.loading {
    pointer-events: none;
    opacity: 0.6;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--cyan-cedit);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
