/* ========================================
   Quiz Creator CSS
   Styles used only on the /quiz/creator page.
   quiz.css is still loaded for shared styles
   (buttons, modals, input-group, base layout).
   ======================================== */

/* Creator Buttons Container */
.creator-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

.creator-json-btns {
    width: 100%;
    display: flex;
    gap: 8px;
    justify-content: center;
}

.json-btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.72rem;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1.5px solid #ccc;
    background: transparent;
    color: #999;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.json-btn:hover {
    border-color: #888;
    color: #555;
}

.mode-btn.secondary-btn {
    background: linear-gradient(135deg, #718096, #4A5568);
    font-size: 1.1em;
    padding: 14px 28px;
    box-shadow: var(--shadow-md);
}

.mode-btn.secondary-btn:hover {
    background: linear-gradient(135deg, #4A5568, #2D3748);
    transform: translateY(-3px) scale(1.03);
    box-shadow: var(--shadow-lg);
}

.mode-btn.secondary-btn:active {
    transform: translateY(-1px) scale(1.01);
}

/* Inline group: selector + revealed sub-field side by side */
.q-inline-group {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.q-inline-group .input-group {
    flex: 1;
    min-width: 140px;
    margin-bottom: 0;
}


/* Visual divider between section adder and question adder */
.creator-section-divider {
    border: none;
    border-top: 2px dashed #e0e0e0;
    margin: 8px 0 24px;
    opacity: 0.7;
}

/* Creator Mode Styles */
.creator-mode {
    text-align: left;
    padding: 30px;
    background: #fafafa;
    border-radius: 20px;
}

/* Creator layout improvements */
.creator-mode .creator-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Primary action when starting from creator */
.start-from-creator {
    background: var(--gradient-warm);
    animation: startFromCreatorPulse 2s ease-in-out infinite;
}
.start-from-creator:hover {
    background: linear-gradient(135deg, #9D4EDD, #FF5E78);
    transform: translateY(-4px) scale(1.05);
    box-shadow: var(--shadow-xl), var(--glow-purple);
}

@keyframes startFromCreatorPulse {
    0%, 100% {
        box-shadow: var(--shadow-md);
    }
    50% {
        box-shadow: var(--shadow-lg), var(--glow-purple);
    }
}

.creator-section {
    margin-bottom: 25px;
}

.creator-section h3 {
    font-family: 'Fredoka', sans-serif;
    margin-bottom: 20px;
    color: transparent;
    background: var(--gradient-main);
    background-clip: text;
    -webkit-background-clip: text;
    font-size: 1.6em;
    font-weight: 700;
}

/* Quiz mode select — subtle attention pulse (3 times) when editor opens */
#quizMode.mode-pulse {
    animation: quizModePulse 1.1s ease-in-out 3;
}

@keyframes quizModePulse {
    0%, 100% {
        border-color: #e0e0e0;
        box-shadow: none;
    }
    50% {
        border-color: rgba(91, 95, 255, 0.55);
        box-shadow: 0 0 0 3px rgba(91, 95, 255, 0.12);
    }
}

.add-question-btn {
    padding: 14px 32px;
    background: linear-gradient(135deg, #4ECDC4, #44A08D);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.15em;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: var(--shadow-md);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.add-question-btn:hover {
    background: linear-gradient(135deg, #44A08D, #2d8b73);
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-lg), var(--glow-success);
}

.questions-list {
    margin-top: 20px;
    max-height: none;
    overflow-y: visible;
}

.question-item {
    background: linear-gradient(135deg, #fff9f0, #fff3e0);
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 15px;
    border-left: 6px solid var(--color-primary);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.question-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: var(--gradient-main);
}

.question-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow-md);
}

.question-item h4 {
    font-family: 'Fredoka', sans-serif;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.question-item p {
    color: #555;
    margin: 5px 0;
    font-size: 0.95em;
}

.delete-btn {
    background: linear-gradient(135deg, #FF5E78, #ff4757);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: var(--shadow-sm);
}

.delete-btn:hover {
    background: linear-gradient(135deg, #ff4757, #ee5a6f);
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-md);
}

.question-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.question-item-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.reorder-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.reorder-btn {
    background: linear-gradient(135deg, #4ECDC4, #3ab5ad);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8em;
    font-weight: 600;
    font-family: 'Fredoka', sans-serif;
    transition: all 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 2px 6px rgba(78, 205, 196, 0.3);
    min-width: 32px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reorder-btn:hover {
    background: linear-gradient(135deg, #3ab5ad, #2a9d96);
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(78, 205, 196, 0.5);
}

.reorder-btn:active {
    transform: scale(0.95);
}

.reorder-btn-placeholder {
    width: 32px;
    height: 28px;
    display: block;
}

/* Section Divider in Editor */
.section-divider-item {
    background: linear-gradient(135deg, #f0f4ff, #e8ecff);
    border: 2px dashed #7c91f5;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.section-divider-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-divider-icon {
    font-size: 1.2em;
    color: #5c6bc0;
    flex-shrink: 0;
}

.section-divider-title {
    font-weight: 700;
    color: #3949ab;
    font-size: 0.95em;
    flex: 1;
}

.section-divider-desc {
    margin: 4px 0 0 44px;
    font-size: 0.82em;
    color: #555;
}

/* Section adder form */
.section-adder .section-adder-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
}

.section-adder .section-adder-fields input,
.section-adder .section-adder-fields textarea {
    flex: 1;
    min-width: 140px;
    padding: 8px 10px;
    border: 2px solid #c5cae9;
    border-radius: 8px;
    font-size: 0.9em;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.section-adder .section-adder-fields input:focus,
.section-adder .section-adder-fields textarea:focus {
    outline: none;
    border-color: #7c91f5;
}

.section-add-btn {
    white-space: nowrap;
}

/* Table Creator Styles */
.table-controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    padding: 12px 24px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1em;
    font-weight: 600;
    background: var(--gradient-cool);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: var(--shadow-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-btn:hover {
    background: linear-gradient(135deg, #5B5FFF, #4947d4);
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-md), var(--glow-blue);
}

#tableEditorContainer {
    overflow-x: auto;
    max-width: 100%;
}

.table-editor {
    border-collapse: collapse;
    width: 100%;
    margin-top: 20px;
    min-width: auto;
}

.table-editor th, .table-editor td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
    position: relative;
}

.table-editor th {
    background-color: #f2f2f2;
}

.table-editor th input {
    width: calc(100% - 20px);
    border: none;
    background: transparent;
    text-align: center;
    font-weight: bold;
    min-width: 80px;
    box-sizing: border-box;
}

.table-editor td {
    cursor: pointer;
    min-width: 100px;
    height: 60px;
    background-color: #f9f9f9;
}

.table-editor td:hover {
    background-color: #e9e9e9;
}

.table-editor td.filled {
    background-color: #d4edda;
    font-weight: bold;
}

.table-editor td.disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    color: #fff;
}

.delete-icon {
    cursor: pointer;
    color: #ff6b6b;
    font-weight: bold;
    font-size: 1.2em;
    padding: 0 5px;
}

.delete-icon:hover {
    color: #ff0000;
}

/* ========================================
   AI QUESTION GENERATION
   ======================================== */

.creator-question-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 8px;
}

.ai-generate-btn {
    padding: 14px 28px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 50px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: var(--shadow-md);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.ai-generate-btn:hover {
    background: linear-gradient(135deg, #5a6fd6, #6a3d96);
    transform: translateY(-4px) scale(1.05);
    box-shadow: var(--shadow-xl), 0 0 30px rgba(102, 126, 234, 0.4);
}

.ai-generate-btn:active {
    transform: translateY(-2px) scale(1.02);
}

/* AI Modal */
.ai-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    animation: modalFadeIn 0.3s ease-out;
}

.ai-modal-box {
    background: white;
    border-radius: 25px;
    padding: 35px;
    width: 85%;
    max-width: 520px;
    box-shadow: var(--shadow-xl);
    animation: modalSlideUp 0.4s ease-out;
    max-height: 85vh;
    overflow-y: auto;
    box-sizing: border-box;
}

.ai-modal-box h3 {
    margin: 0 0 20px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.5em;
    font-weight: 700;
    color: transparent;
    background: linear-gradient(135deg, #667eea, #764ba2);
    background-clip: text;
    -webkit-background-clip: text;
}

.ai-modal-box textarea {
    width: 100%;
    resize: vertical;
    min-height: 80px;
    box-sizing: border-box;
}

.ai-modal-box input[type="number"] {
    width: 100px;
}

.ai-modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Loading state */
.ai-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #667eea;
    font-size: 0.95rem;
    margin-top: 12px;
}

.ai-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(102, 126, 234, 0.25);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: ai-spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes ai-spin {
    to { transform: rotate(360deg); }
}

/* Two-step modal extras */
.ai-size-row {
    display: flex;
    gap: 20px;
}

.ai-size-row .input-group {
    flex: 1;
}

.ai-themes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.ai-themes-header label {
    margin-bottom: 0;
}

.ai-suggest-btn {
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 20px;
    border: 2px solid #667eea;
    background: transparent;
    color: #667eea;
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    transition: background 0.2s, color 0.2s;
}

.ai-suggest-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

.ai-suggest-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.ai-theme-inputs {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-theme-input {
    width: 100%;
    box-sizing: border-box;
}

.ai-loading-center {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 0;
    gap: 14px;
    font-size: 1rem;
}

.ai-spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 4px;
}

.ai-limit-hint {
    margin: 4px 0 12px;
    font-size: 0.78rem;
    color: #888;
}

/* Responsive */
@media (max-width: 768px) {
    .creator-mode {
        padding: 20px;
    }
}
