/* AI Quiz Generator Enhanced Styles */

/* Import Font Awesome for icons */
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css');

/* Root Variables */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;
    --light-bg: #f8fafc;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

.quiz-generator-container1 {
    max-width: 900px;
    width: 900px;
    margin: 5px auto;
    padding: 5px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Header Styles */
.quiz-header {
    text-align: center;
    padding: 15px 10px;
    margin-bottom: 15px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.quiz-header h2 {
    color: var(--primary-color);
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.header-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0;
    font-weight: 400;
}

/* Form Container */
.form-container {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    box-shadow: var(--box-shadow);
    width: 100%;
    max-width: 1100px;
    box-sizing: border-box;
}

/* Form Actions inside container */
.form-actions {
    text-align: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Form Row and Group Styles */
.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: auto;
    height: fit-content;
}

.form-group.topic-group {
    flex: 2;
    min-width: 100%;
}

.form-group label {
    display: flex;
    align-items: center;
    height: fit-content;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group label i {
    color: var(--primary-color);
    font-size: 15px;
}

/* Input Styles */
.form-group select,
.form-group textarea,
.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
    box-sizing: border-box;
    background: #fff;
    font-family: inherit;
    height: fit-content;
}

.form-group select:focus,
.form-group textarea:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: #fff;
}

.form-group select:hover,
.form-group textarea:hover,
.form-group input:hover {
    border-color: var(--primary-dark);
}

.form-group textarea {
    resize: vertical;
    min-height: 75px;
    line-height: 1.5;
}

/* Voice Input Container - Fixed Design */
.voice-input-container {
    position: relative;
    display: flex;
    align-items: stretch;
    border-radius: var(--border-radius);
    border: 2px solid var(--border-color);
    background: #fff;
    transition: var(--transition);
}

.voice-input-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.voice-input-container:hover {
    border-color: var(--primary-dark);
}

.voice-input-container textarea {
    flex: 1;
    border: none !important;
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    padding-right: 50px;
    box-shadow: none !important;
}

.voice-input-container textarea:focus {
    outline: none;
    box-shadow: none !important;
    border: none !important;
}

.voice-controls {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-btn {
    background: var(--primary-color);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.voice-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.4);
}

.voice-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.voice-btn.voice-stop {
    background: var(--danger-color);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.voice-btn.voice-stop:hover:not(:disabled) {
    background: #dc2626;
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.4);
}

.voice-btn.recording {
    animation: voicePulse 1.5s infinite;
    background: #ef4444;
}

@keyframes voicePulse {
    0% { 
        background-color: #ef4444;
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% { 
        background-color: #ef4444;
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% { 
        background-color: #ef4444;
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Voice Status */
.voice-status {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    display: none;
}

.voice-status.listening {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
    display: block;
    animation: pulse 2s infinite;
}

.voice-status.processing {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.2);
    display: block;
}

.voice-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
    display: block;
}

.voice-status.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
    display: block;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.voice-help {
    margin-top: 6px;
    color: var(--text-secondary);
}

.voice-help i {
    color: var(--info-color);
}

.voice-help small {
    font-size: 11px;
}

/* Button Styles */
.generate-button,
.action-button {
    padding: 14px 28px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 160px;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.generate-button {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    font-size: 16px;
    padding: 16px 36px;
    min-width: 200px;
}

.generate-button:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #1e40af 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(37, 99, 235, 0.3);
}

.generate-button:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.action-button.primary {
    background: var(--secondary-color);
    color: white;
}

.action-button.primary:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.action-button.secondary {
    background: var(--text-secondary);
    color: white;
}

.action-button.secondary:hover:not(:disabled) {
    background: #475569;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(100, 116, 139, 0.3);
}

.action-button.danger {
    background: var(--danger-color);
    color: white;
}

.action-button.danger:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

.action-button:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Loading States */
.btn-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Quiz Results */
.quiz-results {
    margin-top: 15px;
}

.results-header {
    text-align: center;
    margin-bottom: 12px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(6, 182, 212, 0.05) 100%);
    border-radius: var(--border-radius);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.results-header h3 {
    color: var(--secondary-color);
    margin: 0 0 6px 0;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.results-subtitle {
    color: var(--text-secondary);
    margin: 0;
    font-size: 13px;
}

#questions-container {
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: var(--box-shadow);
}

.question-item {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.question-item:last-child {
    border-bottom: none;
}

.question-number {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 15px;
    margin-bottom: 10px;
}

.question-text {
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-weight: 500;
}

.question-options {
    margin-bottom: 12px;
}

.option-item {
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--light-bg);
    border-radius: 5px;
    border-left: 3px solid transparent;
    transition: var(--transition);
}

.option-item.correct {
    background: rgba(16, 185, 129, 0.1);
    border-left-color: var(--secondary-color);
    font-weight: 600;
}

.option-label {
    font-weight: 700;
    color: var(--primary-color);
    margin-right: 6px;
}

.question-answer {
    background: rgba(37, 99, 235, 0.1);
    padding: 10px 12px;
    border-radius: 5px;
    margin-bottom: 10px;
    border-left: 3px solid var(--primary-color);
}

.answer-label {
    font-weight: 700;
    color: var(--primary-color);
}

.question-explanation {
    background: rgba(6, 182, 212, 0.1);
    padding: 10px 12px;
    border-radius: 5px;
    border-left: 3px solid var(--info-color);
    font-style: italic;
    color: var(--text-primary);
}

.quiz-actions {
    text-align: center;
    gap: 12px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

/* QR Code Results */
.qr-result {
    margin-top: 20px;
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--box-shadow);
    overflow: hidden;
}

.qr-header {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%);
    border-bottom: 1px solid var(--border-color);
}

.qr-header h3 {
    color: var(--primary-color);
    margin: 0 0 6px 0;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.qr-header p {
    color: var(--text-secondary);
    margin: 0;
}

.qr-content {
    padding: 25px;
    display: flex;
    gap: 25px;
    align-items: center;
}

.qr-code-container {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.qr-info {
    flex: 1;
}

.qr-info p {
    margin: 8px 0;
    font-size: 13px;
}

.qr-info strong {
    color: var(--text-primary);
}

.qr-info span {
    color: var(--text-secondary);
    font-family: monospace;
    background: var(--light-bg);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 12px;
}

.qr-actions {
    margin-top: 15px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Error Messages */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    padding: 12px 16px;
    border-radius: var(--border-radius);
    border: 2px solid rgba(239, 68, 68, 0.2);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.error-message i {
    font-size: 16px;
    flex-shrink: 0;
}

/* Success Messages */
.success-message {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary-color);
    padding: 12px 16px;
    border-radius: var(--border-radius);
    border: 2px solid rgba(16, 185, 129, 0.2);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

/* Print Styles */
@media print {
    .form-container,
    .form-actions,
    .quiz-actions,
    .voice-controls,
    .qr-code-result {
        display: none !important;
    }
    
    .quiz-generator-container1 {
        margin: 0;
        padding: 20px;
        box-shadow: none;
        width: 100%;
        max-width: none;
    }
    
    .quiz-header {
        background: none !important;
        border: none !important;
        padding: 20px 0;
    }
    
    .quiz-header h2 {
        color: #000 !important;
    }
    
    #questions-container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .question-item {
        break-inside: avoid;
    }
    
    .results-header {
        background: none !important;
        border: none !important;
    }
}

/* Responsive Design */
@media (max-width: 920px) {
    .quiz-generator-container1 {
        width: 100%;
        max-width: 100%;
        margin: 5px;
        padding: 5px;
    }
    
    .form-container {
        max-width: 100%;
        padding: 15px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .form-group {
        min-width: 100%;
    }
    
    .quiz-header {
        padding: 12px 10px;
    }
    
    .quiz-header h2 {
        font-size: 24px;
        flex-direction: column;
        gap: 8px;
    }
    
    .quiz-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .action-button,
    .generate-button {
        width: 100%;
        max-width: 280px;
    }
    
    .voice-input-container {
        flex-direction: column;
        border-radius: var(--border-radius);
    }
    
    .voice-input-container textarea {
        border-radius: var(--border-radius) var(--border-radius) 0 0;
        padding-right: 14px;
        margin-bottom: 0;
    }
    
    .voice-controls {
        position: static;
        transform: none;
        padding: 8px;
        background: var(--light-bg);
        border-top: 1px solid var(--border-color);
        border-radius: 0 0 var(--border-radius) var(--border-radius);
        justify-content: center;
    }
    
    .qr-content {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .form-container {
        padding: 12px;
    }
    
    .quiz-header {
        padding: 10px;
    }
    
    .question-item {
        padding: 10px;
    }
    
    .qr-actions {
        flex-direction: column;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus indicators */
.voice-btn:focus,
.action-button:focus,
.generate-button:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-group input:focus {
    outline: 3px solid rgba(37, 99, 235, 0.5);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #1e40af;
        --secondary-color: #059669;
        --danger-color: #dc2626;
        --border-color: #374151;
        --text-primary: #000;
        --text-secondary: #374151;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Loading animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.quiz-results,
.qr-result {
    animation: fadeIn 0.5s ease;
}