/* ====================================
   CULTURE_UNIT - GRID CARTOGRAPHY
   ==================================== */

:root {
    --color-primary: #005068;
    --color-primary-dark: #003d5c;
    --gradient-primary: linear-gradient(135deg, #003d5c 0%, #00546b 100%);
    --color-text: #333;
    --color-text-secondary: #666;
    --color-white: #ffffff;
    --color-background: #fff;
    --color-input-bg: #f0f0f0;
    --color-border: #d0d0d0;
    --font-family: 'Saira Condensed', sans-serif;
    --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 5px 15px rgba(0, 0, 0, 0.1);
    --color-success: #28a745;
    --color-danger: #dc3545;
}

/* === CONTAINER === */
.container {
    max-width: 1400px;
    margin: 20px auto;
    background-color: var(--color-white);
    border-radius: 4px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

/* === HEADER SECTION === */
.cu-header {
    padding: 5px 20px;
    background: var(--gradient-primary);
    color: var(--color-white);
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
}

.cu-header h1 {
    font-size: 24px;
    margin: 0;
    color: white;
}

.cu-header-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.cu-header-controls label {
    font-weight: 500;
    color: var(--color-white);
}

.cu-header-controls select {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background-color: var(--color-white);
    color: var(--color-text);
    cursor: pointer;
    font-size: 14px;
}

/* === MAIN LAYOUT === */
.cu-main-content {
    display: flex;
    height: calc(100vh - 200px);
    min-height: 300px;
    max-height: calc(100vh - 0px);
}

/* === LEFT PANEL === */
.cu-left-panel {
    width: 15%;
    background-color: #f9f9f9;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cu-left-panel-title {
    padding: 15px;
    background-color: #e9ecef;
    font-weight: 600;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
    text-transform: uppercase;
}

.cu-trials-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.cu-trial-item {
    padding: 2px 10px;
    background-color: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    margin-bottom: 8px;
    cursor: grab;
    user-select: none;
    transition: all 0.2s ease;
    position: relative;
}

.cu-trial-item:active {
    cursor: grabbing;
}

.cu-trial-item:hover:not(.placed) {
    background-color: #e7f3ff;
    border-color: var(--color-primary);
    box-shadow: 0 2px 6px rgba(0, 80, 104, 0.2);
}

.cu-trial-item.placed {
    background-color: #f0f8ff;
    cursor: not-allowed;
    opacity: 0.7;
}

.cu-trial-item.placed .cu-trial-name {
    font-weight: 600;
}

.cu-trial-badge {
    display: inline-block;
    background-color: var(--color-success);
    color: var(--color-white);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 5px;
}

.cu-trial-name {
    font-weight: 500;
    font-size: 14px;
}

.cu-trial-id {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 3px;
}

.cu-trial-design {
    display: inline-block;
    background-color: var(--color-primary);
    color: var(--color-white);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    vertical-align: middle;
}
.cu-trial-cancel-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background-color: var(--color-danger);
    color: var(--color-white);
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.cu-trial-cancel-btn:hover {
    background-color: #c82333;
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.3);
}

.cu-trial-cancel-btn:active {
    transform: scale(0.95);
}
/* === RIGHT PANEL === */
.cu-right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cu-grid-controls {
    padding: 15px;
    background-color: #f9f9f9;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    gap: 15px;
    align-items: center;
}

.cu-grid-controls label {
    font-weight: 500;
    font-size: 14px;
}

.cu-grid-controls select {
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background-color: var(--color-white);
    cursor: pointer;
    font-size: 13px;
}

.cu-grid-container {
    flex: 1;
    overflow: auto;
    padding: 20px;
    background-color: #fafafa;
    position: relative;
}

/**
 * Bouton Export Excel de la Culture Unit (après le Zoom MAP)
 */
.cu-btn-export {
    background-color: var(--color-primary);
    color: var(--color-white);
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cu-btn-export:hover {
    background-color: var(--color-primary-dark);
    box-shadow: 0 2px 6px rgba(0, 80, 104, 0.3);
}

.cu-btn-export:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* === GRID CSS === */
.cu-grid-container-with-axes {
    display: flex;
    flex-direction: column;
    width: fit-content;
    gap: 0;
    zoom: 100%
}

.cu-axis-top {
    display: flex;
    margin-bottom: 0;
    gap: 0;
}

.cu-axis-corner {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.cu-axis-labels-x {
    display: grid;
    background-color: #fafafa;
}

.cu-axis-label-x {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    color: var(--color-text);
    height: 40px;
}

.cu-axis-left-and-grid {
    display: flex;
    gap: 0;
}

.cu-axis-labels-y {
    display: grid;
    background-color: #fafafa;
    width: 40px;
}

.cu-axis-label-y {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    color: var(--color-text);
    width: 40px;
    flex-shrink: 0;
}

.cu-grid {
    display: grid;
    gap: 2px;
    background-color: #ddd;
    padding: 2px;
    width: fit-content;
    position: relative;
}

.cu-grid-cell {
    aspect-ratio: 1 / 3;
    min-width: 25px;
    background-color: var(--color-white);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 500;
    user-select: none;
    transition: background-color 0.15s ease;
    position: relative;
    overflow: hidden;
}

.cu-grid-cell.drop-zone {
    background-color: #e7f3ff;
    border: 2px dashed var(--color-primary);
}

.cu-grid-cell.invalid-drop {
    background-color: #ffe7e7;
    border: 2px dashed var(--color-danger);
}

/* === TRIAL CONTAINERS === */
.cu-trial-container {
    position: absolute;
    border: 2px solid var(--color-text);
    background-color: rgba(0, 80, 104, 0.05);
    pointer-events: none;
    display: flex;
    align-items: flex-end;
    padding: 5px;
}

.cu-trial-label {
    background-color: rgba(0, 0, 0, 0.8);
    color: var(--color-white);
    padding: 3px 6px;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    position: absolute;
    bottom: 2px;
    left: 2px;
    z-index: 10;
}

.cu-trial-first-label {
    position: absolute;
    z-index: 20;
    transform: translateY(-100%);
    padding: 3px 6px;
    border-radius: 2px;
    background-color: rgba(0, 0, 0, .8);
    color: var(--color-white);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
}

/* === DRAG & DROP === */
.cu-trial-item.dragging {
    opacity: 0.6;
    transform: scale(0.95);
}

.cu-trial-rep-btn.dragging {
    opacity: 0.6;
    cursor: grabbing;
}

/* === NOTIFICATIONS === */
.cu-notification {
    position: fixed;
    top: 100px;
    right: 20px;
    padding: 15px 20px;
    background-color: var(--color-white);
    border-left: 4px solid var(--color-primary);
    border-radius: 4px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    animation: cu-slideIn 0.3s ease;
}

.cu-notification.error {
    border-left-color: var(--color-danger);
    background-color: #fff5f5;
}

.cu-notification.success {
    border-left-color: var(--color-success);
    background-color: #f0fdf4;
}

@keyframes cu-slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* === CONTEXT MENU === */
.cu-context-menu {
    position: fixed;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    display: none;
    min-width: 180px;
}

.cu-context-menu.active {
    display: block;
}

.cu-context-menu-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: #005068;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.cu-context-menu-item + .cu-context-menu-item {
    border-top: 1px solid #eee;
}

.cu-context-menu-item i {
    margin-right: 6px;
}

.cu-context-menu-item:hover {
    background-color: #f5f5f5;
}

.cu-context-menu-item.danger {
    color: var(--color-danger);
}

/* === LOADING === */
.cu-loading {
    text-align: center;
    padding: 40px;
    color: #999;
}

.cu-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--color-primary);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: cu-spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes cu-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    .cu-left-panel {
        width: 20%;
    }
    .cu-grid-cell {
        min-width: 20px;
        font-size: 8px;
    }
    .cu-main-content {
        height: calc(100vh - 280px);
    }
}
/* ===== MODE PLACEMENT MANUEL PAR PLAGE ===== */

/**
 * Panel d'informations du mode placement manuel
 */
.cu-manual-placement-panel {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
    border: 2px solid #ff9800;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.2);
}

.cu-manual-placement-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: bold;
    color: #e65100;
    font-size: 14px;
}

.cu-manual-placement-close {
    background: none;
    border: none;
    color: #e65100;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.cu-manual-placement-close:hover {
    background-color: rgba(230, 81, 0, 0.1);
}

.cu-manual-placement-info {
    font-size: 12px;
    color: #555;
    margin-bottom: 8px;
    line-height: 1.5;
}

.cu-manual-placement-info p {
    margin: 4px 0;
}

/*.cu-manual-placement-instructions {
    background-color: rgba(255, 255, 255, 0.8);
    border-left: 3px solid #ff9800;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    color: #333;
   
}*/

.cu-manual-placement-instructions p {
    margin: 4px 0;
}

/**
 * Bouton placement manuel dans la liste des essais
 */
.cu-trial-manual-btn {
    background-color: #ff9800;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cu-trial-manual-btn:hover {
    background-color: #f57c00;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.cu-trial-manual-btn:active {
    transform: scale(0.95);
}

.cu-trial-manual-btn.active {
    background-color: #d84315;
    box-shadow: 0 0 8px rgba(216, 67, 21, 0.6);
}

/**
 * Badge pour essais en mode placement manuel
 */
.cu-trial-item.manual-mode-active {
    background-color: #fff8e1;
    border-left: 4px solid #ff9800;
}

.cu-trial-badge.manual-mode {
    background-color: #ff6f00;
    color: white;
    animation: badgePulse 1.5s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/**
 * Cellules de la grille en mode placement manuel
 */

/* Position de début (clic gauche) */
.cu-grid-cell.manual-placement-range-start {
    background-color: #81c784 !important;
    border: 2px solid #2e7d32;
    box-shadow: inset 0 0 6px rgba(46, 125, 50, 0.5), 0 0 8px rgba(46, 125, 50, 0.4);
    font-weight: bold;
    color: white;
}

.cu-grid-cell.manual-placement-range-start::before {
    content: '⬤';
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Zone de placement (preview de la plage) */
.cu-grid-cell.manual-placement-range-preview {
    background-color: #fff59d !important;
    border: 1px dashed #f9a825;
    box-shadow: inset 0 0 3px rgba(249, 168, 37, 0.3);
}

/**
 * Curseur personnalisé en mode placement manuel
 */
.cu-grid {
    transition: background-color 0.3s ease;
}

/* Survol des cellules en mode placement manuel */
.cu-manual-placement-panel {
    /* Panel visible = mode actif */
}

/* Amélioration visuelle : légère transparence de fond lors du mode placement */
.cu-grid-container {
    position: relative;
}

.cu-grid-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    border-radius: 4px;
    transition: background-color 0.2s;
}

/**
 * Animation pour les cellules en mode placement manuel
 */
@keyframes manualPlacementGlow {
    0%, 100% {
        box-shadow: inset 0 0 3px rgba(249, 168, 37, 0.3);
    }
    50% {
        box-shadow: inset 0 0 6px rgba(249, 168, 37, 0.6), 0 0 4px rgba(249, 168, 37, 0.3);
    }
}

.cu-grid-cell.manual-placement-range-preview {
    animation: manualPlacementGlow 2s ease-in-out infinite;
}

.cu-grid-cell.manual-placement-selected {
    background: #ffe082 !important;
    outline: 2px solid #ef6c00;
    outline-offset: -2px;
}

.cu-direction-dialog[hidden] { display: none; }
.cu-direction-dialog {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, .45);
}
.cu-direction-dialog-content {
    width: min(100%, 420px);
    padding: 1.25rem;
    border-radius: 8px;
    background: var(--card-bg, #fff);
    color: var(--text-color, #222);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
}
.cu-direction-options { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: 1rem 0; }
.cu-direction-dialog button, #manual-place-selected { cursor: pointer; }
.cu-direction-dialog button { padding: .55rem .75rem; }

/**
 * Message de progression en mode placement
 */
#manual-placement-progress {
    font-size: 13px;
    color: #d32f2f;
    font-weight: bold;
}

/* Positionnement des essais partiellement placés */
.cu-trial-item {
    position: relative;
    transition: all 0.2s ease;
}

.cu-trial-item.manual-mode-active {
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

/**
 * Bouton annuler placement
 */
.cu-trial-cancel-btn {
    background-color: #d32f2f;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cu-trial-cancel-btn:hover {
    background-color: #b71c1c;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(211, 47, 47, 0.3);
}

.cu-trial-cancel-btn:active {
    transform: scale(0.95);
}

/**
 * Badge "placé"
 */
.cu-trial-badge {
    background-color: #4caf50;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    margin-left: 6px;
    display: inline-block;
}

/**
 * Panel d'informations du mode placement manuel
 */
.cu-manual-placement-panel {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
    border: 2px solid #ff9800;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.2);
    animation: slideDown 0.3s ease;
    position: relative;
}

.cu-manual-placement-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: bold;
    color: #e65100;
    font-size: 14px;
}

.cu-manual-placement-close {
    background: none;
    border: none;
    color: #e65100;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.cu-manual-placement-close:hover {
    background-color: rgba(230, 81, 0, 0.1);
}

.cu-manual-placement-info {
    font-size: 12px;
    color: #555;
    margin-bottom: 8px;
    line-height: 1.5;
}

.cu-manual-placement-info p {
    margin: 4px 0;
}

#manual-placement-progress {
    font-size: 13px;
    color: #d32f2f;
    font-weight: bold;
}

.cu-manual-placement-instructions {
    background-color: rgba(255, 255, 255, 0.8);
    border-left: 3px solid #ff9800;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    color: #333;
     position:absolute;
    top: 10px;
    left: 205px;
}

.cu-manual-placement-instructions p {
    margin: 4px 0;
}

/**
 * Bouton placement manuel dans la liste des essais
 */
.cu-trial-manual-btn {
    background-color: #ff9800;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cu-trial-manual-btn:hover {
    background-color: #f57c00;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.cu-trial-manual-btn:active {
    transform: scale(0.95);
}

.cu-trial-manual-btn.active {
    background-color: #d84315;
    box-shadow: 0 0 8px rgba(216, 67, 21, 0.6);
}

/**
 * Badge pour essais en mode placement manuel
 */
.cu-trial-item.manual-mode-active {
    background-color: #fff8e1;
    border-left: 4px solid #ff9800;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.cu-trial-badge.manual-mode {
    background-color: #ff6f00;
    color: white;
    animation: badgePulse 1.5s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/**
 * Cellules de la grille - Début de ligne (clic gauche)
 */
.cu-grid-cell.line-start {
    background-color: #81c784 !important;
    border: 2px solid #2e7d32;
    box-shadow: inset 0 0 6px rgba(46, 125, 50, 0.5), 0 0 8px rgba(46, 125, 50, 0.4);
    font-weight: bold;
    color: white;
    animation: lineStartPulse 1.5s ease-in-out infinite;
}

.cu-grid-cell.line-start::before {
    content: '⬤';
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes lineStartPulse {
    0%, 100% {
        box-shadow: inset 0 0 6px rgba(46, 125, 50, 0.5), 0 0 8px rgba(46, 125, 50, 0.4);
    }
    50% {
        box-shadow: inset 0 0 10px rgba(46, 125, 50, 0.8), 0 0 12px rgba(46, 125, 50, 0.6);
    }
}

/**
 * Bouton annuler placement
 */
.cu-trial-cancel-btn {
    background-color: #d32f2f;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cu-trial-cancel-btn:hover {
    background-color: #b71c1c;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(211, 47, 47, 0.3);
}

.cu-trial-cancel-btn:active {
    transform: scale(0.95);
}

/**
 * Badge "placé"
 */
.cu-trial-badge {
    background-color: #4caf50;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    margin-left: 6px;
    display: inline-block;
}

/**
 * Améliorations visuelles pour la grille
 */
.cu-grid-cell {
    cursor: crosshair;
    transition: all 0.15s ease;
}

.cu-grid-cell:hover {
    opacity: 0.8;
    transform: scale(1.02);
}

/**
 * Animation subtile pour le panel
 */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Positionnement des essais */
.cu-trial-item {
    position: relative;
    transition: all 0.2s ease;
}
