/* Reset and base styles */
* {
    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: 10px;
}

/* Container with responsive height */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    padding: 20px;
    height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Iframe specific styling */
@media (max-height: 500px) {
    .container {
        height: 450px;
    }
}

/* Progress section */
.progress-section {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    white-space: nowrap;
}

/* Text passage styling */
.text-passage {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    line-height: 1.6;
    font-size: 16px;
    flex-shrink: 0;
    border-left: 4px solid #667eea;
}

.text-passage p {
    margin-bottom: 15px;
}

.text-passage p:last-child {
    margin-bottom: 0;
}

/* Draggable elements */
.draggable {
    background: #fff3cd;
    border: 2px solid #ffc107;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: grab;
    display: inline-block;
    margin: 2px;
    font-weight: 600;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
}

.draggable:hover {
    background: #fff8e1;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3);
}

.draggable:active {
    cursor: grabbing;
    transform: scale(1.05);
}

.draggable.dragging {
    opacity: 0.7;
    z-index: 1000;
    transform: rotate(5deg);
}

.draggable.placed {
    background: #d4edda;
    border-color: #28a745;
    cursor: default;
}

.draggable.incorrect {
    background: #f8d7da;
    border-color: #dc3545;
    animation: shake 0.5s ease-in-out;
}

/* Drop zones */
.drop-zones {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    flex: 1;
}

.drop-zone {
    background: #ffffff;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s ease;
    min-height: 120px;
}

.drop-zone h3 {
    color: #495057;
    margin-bottom: 5px;
    font-size: 18px;
    text-align: center;
}

.category-description {
    color: #6c757d;
    font-size: 12px;
    text-align: center;
    margin-bottom: 15px;
    font-style: italic;
}

.drop-area {
    min-height: 60px;
    border-radius: 4px;
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
    align-content: flex-start;
}

.drop-zone.drag-over {
    border-color: #007bff;
    background: #e3f2fd;
    transform: scale(1.02);
}

.drop-zone.correct {
    border-color: #28a745;
    background: #d4edda;
}

.drop-zone.incorrect {
    border-color: #dc3545;
    background: #f8d7da;
}

/* Controls section */
.controls {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    white-space: nowrap;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.btn-primary:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.score-display {
    font-weight: 600;
    color: #495057;
    font-size: 18px;
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 2px solid #dee2e6;
}

/* Feedback area */
.feedback {
    text-align: center;
    padding: 15px;
    border-radius: 6px;
    font-weight: 600;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feedback.success {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.feedback.error {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

.feedback.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 2px solid #bee5eb;
}

/* Hint tooltip */
.hint-tooltip {
    position: absolute;
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 1001;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    max-width: 200px;
    text-align: center;
}

.hint-tooltip.show {
    opacity: 1;
}

.hint-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.bounce {
    animation: bounce 0.6s ease;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .text-passage {
        font-size: 14px;
        padding: 15px;
    }
    
    .drop-zones {
        grid-template-columns: 1fr;
    }
    
    .controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn {
        width: 100%;
        max-width: 300px;
    }
    
    .draggable {
        font-size: 14px;
        padding: 6px 10px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .draggable {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .btn {
        min-height: 48px;
    }
}