/* ============================================
   Generator Kuis Moodle v4.0 PRO + AI
   Beautiful Gradient Design
   © 2025 De Indra
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.main-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ============================================
   Header Section
   ============================================ */
.header-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    text-align: center;
}

.header-section h1 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.header-section p {
    color: #666;
    font-size: 1.1rem;
    margin: 5px 0;
}

.header-section p.text-muted {
    font-size: 0.9rem;
    color: #999;
}

/* ============================================
   Version Badge
   ============================================ */
.version-badge {
    position: fixed;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 1000;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: all 0.3s ease;
}

.version-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

/* ============================================
   AI Badge (NEW)
   ============================================ */
.ai-badge {
    position: fixed;
    top: 50px;
    right: 10px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 1000;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
}

.card h3 {
    color: #333;
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card h3 i {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.5rem;
}

/* ============================================
   Form Controls
   ============================================ */
.form-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    display: block;
}

.form-control,
.form-select,
textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.form-control:focus,
.form-select:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.btn-outline-primary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-outline-primary:hover {
    background: #667eea;
    color: white;
}

.btn-ai {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-ai:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

/* ============================================
   AI Assistant Panel (NEW)
   ============================================ */
.ai-panel {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(139, 92, 246, 0.3);
}

.ai-panel h4 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-panel .ai-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
}

.ai-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 2s infinite;
}

/* ============================================
   Question Item
   ============================================ */
.question-item {
    background: white;
    border-left: 4px solid #667eea;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.question-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

/* ============================================
   Badge
   ============================================ */
.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 8px;
}

.badge-primary {
    background: rgba(102, 126, 234, 0.15);
    color: #667eea;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}

/* ============================================
   Math Symbols
   ============================================ */
.math-symbols {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.math-symbol-btn {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.3rem;
}

.math-symbol-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    transform: scale(1.1);
}

/* ============================================
   Math Settings Button
   ============================================ */
.math-settings-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.math-settings-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

/* ============================================
   AI Assistant Button (NEW)
   ============================================ */
.ai-assistant-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border: none;
    box-shadow: 0 5px 20px rgba(139, 92, 246, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-assistant-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.6);
}

.ai-assistant-btn i {
    font-size: 1.5rem;
}

/* ============================================
   Alert
   ============================================ */
.alert {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid #3b82f6;
    color: #1e40af;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid #10b981;
    color: #065f46;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-left: 4px solid #f59e0b;
    color: #92400e;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .header-section {
        padding: 20px;
    }
    
    .header-section h1 {
        font-size: 1.8rem;
    }
    
    .card {
        padding: 20px;
    }
    
    .version-badge {
        top: 8px;
        right: 8px;
        font-size: 0.75rem;
        padding: 6px 12px;
    }
    
    .ai-badge {
        top: 40px;
    }
    
    .math-settings-btn,
    .ai-assistant-btn {
        width: 48px;
        height: 48px;
    }
}

/* ============================================
   Utilities
   ============================================ */
.text-center { text-align: center; }
.text-muted { color: #666; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.d-flex { display: flex; }
.gap-2 { gap: 1rem; }
.w-100 { width: 100%; }

/* ============================================
   FIX: Math Symbols Toolbar
   ============================================ */
.math-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    margin-bottom: 10px;
}

.math-toolbar button {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
}

.math-toolbar button:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: scale(1.1);
}

/* ============================================
   FIX: Stats Cards Header
   ============================================ */
.stats-header {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card-mini {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.stat-card-mini h4 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-card-mini p {
    margin: 5px 0 0 0;
    font-size: 0.85rem;
    color: #666;
}

/* ============================================
   FIX: Question List Buttons
   ============================================ */
.question-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.question-actions .btn {
    flex: 1;
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* ============================================
   Responsive Fix
   ============================================ */
@media (max-width: 768px) {
    .stats-header {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .math-toolbar button {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
}

/* ============================================
   IMPROVED: Math Symbols Grid
   ============================================ */
.math-symbols-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
    gap: 6px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-radius: 10px;
    margin-top: 10px;
}

.math-symbol {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 1.3rem;
    font-weight: 500;
    transition: all 0.2s ease;
    user-select: none;
}

.math-symbol:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.math-symbol:active {
    transform: translateY(0) scale(0.95);
}

/* ============================================
   Text Formatting Buttons
   ============================================ */
.format-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    margin-bottom: 10px;
}

.format-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.format-btn i {
    font-size: 1rem;
}

.format-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.format-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* ============================================
   Helper Text Below Toolbar
   ============================================ */
.toolbar-hint {
    font-size: 0.85rem;
    color: #666;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(102, 126, 234, 0.05);
    border-left: 3px solid #667eea;
    border-radius: 4px;
}

.toolbar-hint code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

/* ============================================
   FIX: Stats Bar
   ============================================ */
.stats-bar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.stats-bar .row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-item {
    text-align: center;
    padding: 15px;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    font-weight: 600;
}

@media (max-width: 768px) {
    .stats-bar .row {
        flex-wrap: wrap;
    }
    
    .stat-item {
        flex: 0 0 50%;
        margin-bottom: 15px;
    }
}

/* ============================================
   FIX: Image Preview in Question List
   ============================================ */
.question-item img {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    display: block;
    margin: 10px 0;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.question-preview-image {
    max-width: 150px;
    max-height: 150px;
    object-fit: cover;
    border-radius: 6px;
    margin: 8px 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.question-preview-image:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Image in form upload preview */
#imagePreview img {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    display: block;
    margin: 10px auto;
    border-radius: 8px;
    border: 2px solid #ddd;
}

/* Option image preview */
.option-image-preview {
    max-width: 120px;
    max-height: 120px;
    object-fit: cover;
    border-radius: 6px;
    margin: 5px 0;
}

/* Thumbnail for list */
.image-thumbnail {
    max-width: 80px;
    max-height: 80px;
    object-fit: cover;
    border-radius: 4px;
    float: left;
    margin-right: 10px;
}

/* Image modal for full view */
.image-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.image-modal-overlay.active {
    display: flex;
}

.image-modal-overlay img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .question-preview-image {
        max-width: 100px;
        max-height: 100px;
    }
    
    .image-thumbnail {
        max-width: 60px;
        max-height: 60px;
    }
}

/* ============================================
   Question Card Layout - Proper Structure
   ============================================ */

/* Main question card container */
.question-card,
.question-item {
    position: relative;
    background: white;
    border-left: 4px solid #667eea;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.question-card:hover,
.question-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

/* Question header (Soal 1, Soal 2, etc) */
.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.question-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

/* Question body content */
.question-body {
    margin-bottom: 15px;
}

.question-text-label {
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
}

.question-text-content {
    color: #666;
    line-height: 1.6;
    margin-bottom: 12px;
}

/* Image in question */
.question-image-wrapper {
    margin: 15px 0;
    text-align: center;
}

/* Options section */
.question-options-wrapper {
    margin: 15px 0;
}

.question-options-label {
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
}

.question-options-list {
    margin-left: 20px;
}

/* Grade/Nilai section */
.question-grade {
    display: inline-block;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    margin: 10px 0;
}

/* Action buttons at bottom */
.question-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

.question-actions .btn {
    flex: 0 0 auto;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .question-card,
    .question-item {
        padding: 15px;
    }
    
    .question-actions {
        flex-direction: column;
    }
    
    .question-actions .btn {
        width: 100%;
    }
}
