/* ===== RESET & 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%);
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* ===== CONTAINER ===== */
.container {
    width: 100%;
    height: 450px;
    background: #ffffff;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* When opened in new tab (not iframe) */
@media (min-height: 500px) {
    body.standalone .container {
        height: 90vh;
    }
}

/* ===== HEADER TOOLTIP ===== */
.header-tooltip {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
    white-space: nowrap;
}

.container:hover .header-tooltip {
    opacity: 1;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
    overflow-y: auto;
}

/* ===== INSTRUCTIONS PANEL ===== */
.instructions-panel {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 12px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.instruction-text {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
    min-width: 200px;
}

.progress-info {
    display: flex;
    gap: 15px;
    font-size: 13px;
    font-weight: 500;
}

.score {
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 12px;
}

/* ===== DROP ZONES ===== */
.drop-zones {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    flex-shrink: 0;
}

.drop-zone {
    background: #f8f9fa;
    border: 3px dashed #cbd5e0;
    border-radius: 12px;
    padding: 10px;
    transition: all 0.3s;
    min-height: 120px;
    /* ADDED: Cursor pointer for click interaction */
    cursor: pointer;
}

.drop-zone.countable {
    border-color: #48bb78;
}

.drop-zone.uncountable {
    border-color: #ed8936;
}

.drop-zone.drag-over {
    background: #e6fffa;
    border-style: solid;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ADDED: Highlight drop zone when a word is selected for click interaction */
.drop-zone.clickable-highlight {
    background: #fff5e6;
    border-style: solid;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(102, 126, 234, 0.5); }
}

.zone-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.zone-icon {
    font-size: 24px;
}

.zone-title {
    font-size: 15px;
    font-weight: 700;
    color: #2d3748;
}

.zone-hint {
    font-size: 11px;
    color: #718096;
    margin-bottom: 4px;
    font-style: italic;
}

.zone-examples {
    font-size: 10px;
    color: #a0aec0;
    margin-bottom: 8px;
    transition: opacity 0.3s;
}

.zone-examples.hidden {
    opacity: 0;
}

.drop-area {
    min-height: 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: center;
}

/* ===== WORD AREA - MODIFIED: Display all words at once ===== */
.word-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    padding: 10px;
}

.word-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
    max-width: 100%;
}

/* MODIFIED: Word cards now include graphics/icons for visual learning */
.word-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: move;
    user-select: none;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s;
    touch-action: none;
    min-width: 80px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
}

/* ADDED: Selected state for click interaction */
.word-card.selected {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.8);
    border: 3px solid #ffd700;
    animation: selectedGlow 1s infinite alternate;
}

@keyframes selectedGlow {
    0% { box-shadow: 0 8px 20px rgba(102, 126, 234, 0.8); }
    100% { box-shadow: 0 8px 25px rgba(255, 215, 0, 0.9); }
}

/* ADDED: Style for the graphic icon in word cards */
.word-icon {
    font-size: 28px;
    display: block;
    margin-bottom: 2px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* ADDED: Style for the word text below the icon */
.word-text {
    font-size: 12px;
    font-weight: 700;
    text-transform: capitalize;
}

.word-card:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.word-card:active {
    transform: scale(0.95);
}

.word-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

/* MODIFIED: Dropped cards maintain icon visibility */
.word-card.dropped {
    background: #e2e8f0;
    color: #2d3748;
    cursor: default;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    font-size: 11px;
    padding: 6px 8px;
}

/* MODIFIED: Dropped cards can show tooltips on hover - change cursor to help */
.word-card.dropped:hover {
    cursor: help;
}

.word-card.correct {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    animation: correctPulse 0.5s;
}

.word-card.incorrect {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: white;
    animation: shake 0.5s;
}

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

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

/* ===== ADDED: WORD TOOLTIP STYLES - Shows on hover for learning tips ===== */
/* MODIFIED: Tooltip only visible for dropped words */
.word-tooltip {
    position: fixed;
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    color: white;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 12px;
    max-width: 280px;
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(102, 126, 234, 0.5);
}

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

.word-tooltip .tooltip-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.word-tooltip .tooltip-title {
    font-weight: 700;
    font-size: 13px;
    color: #ffd700;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 6px;
}

.word-tooltip .tooltip-description {
    line-height: 1.6;
    color: #e2e8f0;
    font-size: 11px;
}

/* ADDED: Arrow pointer for tooltip */
.word-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #2d3748;
}

/* ===== FEEDBACK PANEL ===== */
.feedback-panel {
    background: #edf2f7;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s;
    /* ADDED: Allow for multi-line feedback */
    flex-direction: column;
}

.feedback-panel.show {
    opacity: 1;
}

.feedback-panel.correct {
    background: #c6f6d5;
    color: #22543d;
}

.feedback-panel.incorrect {
    background: #fed7d7;
    color: #742a2a;
}

#feedbackIcon {
    font-size: 20px;
}

/* ADDED: Style for detailed feedback text */
#feedbackText {
    line-height: 1.5;
}

.feedback-details {
    font-size: 12px;
    margin-top: 8px;
    padding: 8px;
    background: rgba(255,255,255,0.5);
    border-radius: 6px;
    max-height: 150px;
    overflow-y: auto;
    text-align: left;
}

.feedback-item {
    margin-bottom: 6px;
    padding: 4px;
    border-left: 3px solid #cbd5e0;
    padding-left: 8px;
}

.feedback-item.correct {
    border-left-color: #48bb78;
}

.feedback-item.incorrect {
    border-left-color: #f56565;
}

/* ===== CONTROLS ===== */
.controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 44px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-check {
    background: #667eea;
    color: white;
}

.btn-next {
    background: #48bb78;
    color: white;
}

.btn-reset {
    background: #ed8936;
    color: white;
}

.btn-analytics {
    background: #4299e1;
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== ANALYTICS PANEL ===== */
.analytics-panel {
    background: white;
    border-top: 3px solid #667eea;
    max-height: 250px;
    transition: max-height 0.3s, padding 0.3s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.analytics-panel.collapsed {
    max-height: 0;
    padding: 0;
    border: none;
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
}

.analytics-header h3 {
    font-size: 14px;
    color: #2d3748;
    margin: 0;
}

.close-btn {
    background: #e53e3e;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.close-btn:hover {
    background: #c53030;
    transform: rotate(90deg);
}

.analytics-tabs {
    display: flex;
    background: #edf2f7;
    padding: 0 12px;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: #718096;
    border-bottom: 2px solid transparent;
    transition: all 0.3s;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.analytics-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.analytics-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.btn-small {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    background: #e2e8f0;
    color: #2d3748;
    transition: all 0.3s;
}

.btn-small:hover {
    background: #cbd5e0;
}

.log-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
}

.log-entry {
    background: #f7fafc;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 11px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    border-left: 3px solid #cbd5e0;
}

.log-entry.correct {
    border-left-color: #48bb78;
    background: #f0fff4;
}

.log-entry.incorrect {
    border-left-color: #f56565;
    background: #fff5f5;
}

.timestamp {
    color: #718096;
    font-weight: 600;
    min-width: 45px;
}

.action-icon {
    font-size: 14px;
}

.action-desc {
    flex: 1;
    color: #2d3748;
    line-height: 1.4;
}

.quiz-details {
    margin-top: 4px;
    padding-left: 16px;
    font-size: 10px;
    color: #4a5568;
}

/* ===== HELP TOOLTIP ===== */
.help-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    border: none;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: all 0.3s;
    z-index: 100;
}

.help-btn:hover {
    background: #5a67d8;
    transform: scale(1.1);
}

.help-tooltip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    max-width: 320px;
    z-index: 1001;
    display: none;
}

.help-tooltip.show {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.tooltip-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #e53e3e;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.tooltip-close:hover {
    background: #c53030;
    transform: rotate(90deg);
}

.help-tooltip h4 {
    color: #2d3748;
    margin-bottom: 10px;
    font-size: 15px;
}

.help-tooltip ol {
    margin-left: 18px;
    margin-bottom: 10px;
}

.help-tooltip li {
    margin-bottom: 6px;
    font-size: 12px;
    color: #4a5568;
    line-height: 1.5;
}

.help-tooltip p {
    font-size: 12px;
    color: #718096;
    background: #edf2f7;
    padding: 8px;
    border-radius: 6px;
    margin: 0;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 600px) {
    .drop-zones {
        grid-template-columns: 1fr;
    }
    
    .instructions-panel {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .word-card {
        font-size: 11px;
        padding: 6px 8px;
        min-width: 70px;
    }
    
    /* MODIFIED: Adjust icon size for mobile */
    .word-icon {
        font-size: 24px;
    }
    
    .word-text {
        font-size: 11px;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    /* ADDED: Adjust tooltip for mobile */
    .word-tooltip {
        max-width: 220px;
        font-size: 11px;
    }
}

/* ===== SCROLLBAR STYLING ===== */
.log-container::-webkit-scrollbar,
.analytics-content::-webkit-scrollbar,
.main-content::-webkit-scrollbar,
.feedback-details::-webkit-scrollbar {
    width: 6px;
}

.log-container::-webkit-scrollbar-track,
.analytics-content::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track,
.feedback-details::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.log-container::-webkit-scrollbar-thumb,
.analytics-content::-webkit-scrollbar-thumb,
.main-content::-webkit-scrollbar-thumb,
.feedback-details::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.log-container::-webkit-scrollbar-thumb:hover,
.analytics-content::-webkit-scrollbar-thumb:hover,
.main-content::-webkit-scrollbar-thumb:hover,
.feedback-details::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}