/* ===============================================
   DRAG & DROP EXERCISE STYLES - VERSION 2.0
   Style moderne pour exercices glisser-déposer
   Compatible RTL (arabe) + Navigation multi-exercices
   =============================================== */

/* VARIABLES CSS */
:root {
    --primary-color: #4ECDC4;
    --secondary-color: #FF6B6B;
    --success-color: #51CF66;
    --error-color: #FF6B6B;
    --warning-color: #FFD93D;
    --info-color: #74C0FC;
    
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8F9FA;
    --bg-tertiary: #E9ECEF;
    
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #6C757D;
    
    --border-color: #DEE2E6;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* RESET ET BASE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Cairo', 'Tahoma', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    direction: rtl;
}

/* CONTENEUR PRINCIPAL */
.exercise-container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 30px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== NAVIGATION MULTI-EXERCICES ==================== */
.exercise-navigation {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    box-shadow: var(--shadow-md);
}

.nav-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav-title {
    font-size: 1.3rem;
    font-weight: bold;
}

.nav-progress {
    font-size: 0.95rem;
    opacity: 0.9;
}

.nav-buttons {
    display: flex;
    gap: 10px;
}

.nav-buttons button {
    padding: 10px 25px;
    font-size: 1rem;
    font-weight: bold;
    border: 2px solid white;
    background: transparent;
    color: white;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.nav-buttons button:hover:not(:disabled) {
    background: white;
    color: #667eea;
    transform: translateY(-2px);
}

.nav-buttons button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .exercise-navigation {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-info {
        text-align: center;
    }
}

/* ==================== HEADER DE L'EXERCICE ==================== */
#exercise-title {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 15px;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

#exercise-consigne {
    font-size: 1.2rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 30px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    border-right: 4px solid var(--primary-color);
}

.hint-text {
    font-size: 0.9rem;
    color: var(--info-color);
    margin-top: 10px;
    font-style: italic;
    background: rgba(116, 192, 252, 0.1);
    padding: 8px 15px;
    border-radius: 20px;
    display: inline-block;
}

/* BADGES DE NIVEAU */
.niveau-badge {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 15px;
    box-shadow: var(--shadow-sm);
}

.niveau-badge.facile {
    background: linear-gradient(135deg, #51CF66 0%, #37B24D 100%);
    color: white;
}

.niveau-badge.متوسط {
    background: linear-gradient(135deg, #FFD93D 0%, #FFA94D 100%);
    color: #333;
}

.niveau-badge.صعب {
    background: linear-gradient(135deg, #FF6B6B 0%, #EE5A6F 100%);
    color: white;
}

/* ZONE DRAG & DROP */
.drag-drop-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .drag-drop-area {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* BANQUE D'ITEMS */
.items-container {
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    min-height: 200px;
    position: relative;
    transition: all var(--transition-normal);
}

.items-container.drag-over {
    background: rgba(116, 192, 252, 0.2);
    border-color: var(--info-color);
    border-style: solid;
    transform: scale(1.01);
}

.items-container::before {
    content: 'بنك الإجابات';
    position: absolute;
    top: -12px;
    right: 15px;
    background: var(--bg-primary);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* ITEMS DRAGGABLES */
.drag-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    margin: 10px;
    border-radius: var(--border-radius-sm);
    cursor: grab;
    user-select: none;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    font-size: 1.1rem;
    font-weight: 500;
    display: inline-block;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

/* Indication visuelle pour le double-clic */
.drag-item::after {
    content: '↩';
    position: absolute;
    top: 2px;
    left: 5px;
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.drop-area .drag-item::after {
    opacity: 0.5;
}

.drop-area .drag-item:hover::after {
    opacity: 1;
}

.drag-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.drag-item:hover::before {
    transform: translateX(100%);
}

.drag-item:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-md);
}

.drag-item:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.drag-item.dragging {
    opacity: 0.7;
    transform: rotate(5deg) scale(1.05);
    cursor: grabbing;
    z-index: 1000;
}

/* CONTENEUR DES ZONES */
.zones-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ZONE DE DÉPÔT */
.drop-zone {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 15px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.zone-label {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 10px;
    padding: 8px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: var(--border-radius-sm);
    text-align: center;
}

.drop-area {
    min-height: 80px;
    background: white;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    position: relative;
}

.drop-area:empty::after {
    content: 'اسحب الإجابة هنا';
    color: var(--text-muted);
    font-size: 0.9rem;
    opacity: 0.6;
}

.drop-area.drag-over {
    background: var(--info-color);
    border-color: var(--primary-color);
    border-style: solid;
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(78, 205, 196, 0.3);
}

/* ÉTATS DE VALIDATION */
.drop-area.correct {
    background: rgba(81, 207, 102, 0.1);
    border-color: var(--success-color);
    border-style: solid;
    animation: successPulse 0.5s ease;
}

.drop-area.incorrect {
    background: rgba(255, 107, 107, 0.1);
    border-color: var(--error-color);
    border-style: solid;
    animation: errorShake 0.5s ease;
}

@keyframes successPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* FEEDBACK DES ZONES */
.zone-feedback {
    margin-top: 10px;
    padding: 10px;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
}

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

.correct-feedback {
    background: rgba(81, 207, 102, 0.2);
    color: #2b8a3e;
    border-right: 3px solid var(--success-color);
}

.incorrect-feedback {
    background: rgba(255, 107, 107, 0.2);
    color: #c92a2a;
    border-right: 3px solid var(--error-color);
}

/* BOUTONS DE CONTRÔLE */
.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.controls button {
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.controls button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.controls button:hover::before {
    width: 300px;
    height: 300px;
}

#btn-verify {
    background: linear-gradient(135deg, #51CF66 0%, #37B24D 100%);
    color: white;
}

#btn-verify:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#btn-verify:active {
    transform: translateY(0);
}

#btn-reset {
    background: linear-gradient(135deg, #FF6B6B 0%, #EE5A6F 100%);
    color: white;
}

#btn-reset:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#btn-reset:active {
    transform: translateY(0);
}

/* FEEDBACK GLOBAL */
.feedback {
    padding: 20px;
    border-radius: var(--border-radius);
    margin-top: 20px;
    text-align: center;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.feedback.hidden {
    display: none;
}

.feedback.success {
    background: linear-gradient(135deg, #51CF66 0%, #37B24D 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(81, 207, 102, 0.3);
}

.feedback.error {
    background: linear-gradient(135deg, #FF6B6B 0%, #EE5A6F 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.3);
}

.feedback-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.feedback-message {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.feedback-score {
    font-size: 1.5rem;
    font-weight: bold;
    margin-top: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-sm);
}

/* CONFETTIS ANIMATION (SUCCÈS) */
@keyframes confetti {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    animation: confetti 3s ease-out forwards;
    pointer-events: none;
}

/* SUPPORT MOBILE AMÉLIORÉ */
@media (max-width: 768px) {
    .exercise-container {
        padding: 20px;
    }
    
    #exercise-title {
        font-size: 1.5rem;
    }
    
    #exercise-consigne {
        font-size: 1rem;
    }
    
    .drag-item {
        padding: 12px 15px;
        font-size: 1rem;
        margin: 8px;
    }
    
    .controls button {
        padding: 12px 30px;
        font-size: 1rem;
    }
    
    .feedback-message {
        font-size: 1.1rem;
    }
    
    .feedback-score {
        font-size: 1.2rem;
    }
}

/* TOUCH FEEDBACK POUR MOBILE */
@media (hover: none) and (pointer: coarse) {
    .drag-item:active {
        opacity: 0.8;
        transform: scale(1.05);
    }
    
    .drop-area:active {
        background: var(--info-color);
    }
}

/* ACCESSIBILITÉ */
.drag-item:focus,
.controls button:focus,
.nav-buttons button:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* IMPRESSION */
@media print {
    body {
        background: white;
    }
    
    .controls, .exercise-navigation {
        display: none;
    }
    
    .feedback {
        border: 2px solid #000;
    }
}


/* =========================
   FIX AFFICHAGE DES CARTES
   ========================= */

.items-container {
    display: flex !important;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 120px;
    padding: 15px;
    border: 2px dashed #aaa;
    background: #f9f9f9;
}

.drag-item {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    min-height: 45px;
    padding: 10px 15px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    color: #000 !important;
    cursor: grab;
    user-select: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.drag-item.dragging {
    opacity: 0.5;
}

.drag-drop-area {
    display: flex !important;
    gap: 20px;
    flex-wrap: wrap;
}

.zones-container {
    flex: 1;
    min-width: 250px;
}

/* MODE SOMBRE (OPTIONNEL) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1A1B1E;
        --bg-secondary: #25262B;
        --bg-tertiary: #2C2E33;
        --text-primary: #C1C2C5;
        --text-secondary: #909296;
        --border-color: #373A40;
    }
    
    body {
        background: linear-gradient(135deg, #1A1B1E 0%, #25262B 100%);
    }
}

