/* Smart Quiz Builder Pro - Frontend Styles */

.sqb-v10-wrapper {
    font-family: 'Tajawal', 'Segoe UI', sans-serif;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    max-width: 900px;
    margin: 20px auto;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.sqb-v10-wrapper * {
    box-sizing: border-box;
}

.sqb-screen {
    display: none;
    padding: 20px;
    animation: fadeIn 0.3s;
}

.sqb-screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Start Screen */
.sqb-start-card {
    text-align: center;
    padding: 40px 20px;
}

.sqb-icon-lg {
    font-size: 3.5em;
    display: block;
    margin-bottom: 15px;
}

.sqb-title {
    font-size: 1.8em;
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 10px;
}

.sqb-meta {
    color: #718096;
    margin-bottom: 25px;
}

.sqb-quote {
    background: #ebf8ff;
    color: #2c5282;
    padding: 15px;
    border-radius: 8px;
    font-style: italic;
    margin-bottom: 25px;
    display: inline-block;
}

.sqb-btn-start {
    background: #3182ce;
    color: white;
    padding: 12px 35px;
    border-radius: 30px;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    transition: 0.2s;
    box-shadow: 0 4px 6px rgba(49, 130, 206, 0.3);
}

.sqb-btn-start:hover {
    transform: scale(1.05);
}

/* Quiz UI */
.sqb-top-bar {
    background: #2d3748;
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sqb-tabs {
    display: flex;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sqb-tab {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    color: #718096;
    font-weight: 600;
    white-space: nowrap;
    flex: 0 0 auto;
    min-width: 60px;
    text-align: center;
    font-size: 0.9rem;
}

.sqb-tab::after {
    content: '';
    display: block;
    clear: both;
}

.sqb-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    background: white;
    border-bottom: 1px solid #edf2f7;
    max-height: 120px;
    overflow-y: auto;
}

.sqb-grid-item {
    width: 32px;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    cursor: pointer;
    background: #fff;
    font-size: 14px;
}

.sqb-tab.active {
    color: #3182ce;
    border-bottom-color: #3182ce;
    background: white;
}

.sqb-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    background: white;
    border-bottom: 1px solid #edf2f7;
    max-height: 120px;
    overflow-y: auto;
}

.sqb-grid-item {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    cursor: pointer;
    background: #fff;
    font-size: 14px;
}

.sqb-grid-item.current {
    border-color: #3182ce;
    background: #ebf8ff;
    color: #2b6cb0;
    font-weight: bold;
}

.sqb-grid-item.answered {
    background: #c6f6d5;
    border-color: #9ae6b4;
    color: #22543d;
}

.sqb-grid-item.flagged {
    border-color: #ed8936;
    color: #ed8936;
    position: relative;
}

.sqb-grid-item.flagged::after {
    content: '•';
    position: absolute;
    top: 0;
    right: 2px;
    color: #ed8936;
}

.sqb-q-body {
    padding: 20px 0;
    min-height: 250px;
}

.sqb-passage {
    background: #fffaf0;
    border-right: 4px solid #ed8936;
    padding: 12px 14px;
    margin-bottom: 12px;
    color: #2d3748;
    border-radius: 4px;
    line-height: 1.7;
}

.sqb-q-text {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 15px;
    color: #1a202c;
}

.sqb-q-img {
    max-width: 100%;
    height: auto;
    margin-bottom: 15px;
    border-radius: 8px;
    border: 1px solid #eee;
    display: block;
}

/* Options with Images */
.sqb-opt {
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
    background: #fff;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: flex-start;
    white-space: normal;
    position: relative;
    padding-inline-end: 40px;
}

.sqb-opt:hover {
    background: #ebf8ff;
    border-color: #bee3f8;
}

.sqb-opt > .sqb-opt-circle {
    margin-top: 4px;
    flex-shrink: 0;
}

.sqb-opt > div {
    min-width: 0;
}

.sqb-opt > img,
.sqb-opt-img {
    max-width: 100%;
    height: auto;
}

.sqb-opt.selected {
    background: #ebf8ff;
    border-color: #3182ce;
    color: #2b6cb0;
    font-weight: bold;
}

.sqb-opt-circle {
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e0;
    border-radius: 50%;
    margin-inline-end: 15px;
    flex-shrink: 0;
}

.sqb-opt.selected .sqb-opt-circle {
    background: #3182ce;
    border-color: #3182ce;
}

.sqb-opt.correct::after,
.sqb-opt.wrong::after {
    position: absolute;
    inset-inline-end: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    line-height: 1;
    font-weight: bold;
}

.sqb-opt.correct::after {
    content: '✓';
    color: #2f855a;
}

.sqb-opt.wrong::after {
    content: '✗';
    color: #c53030;
}

.sqb-opt-img {
    max-height: 80px;
    max-width: 150px;
    margin-inline-start: 10px;
    border-radius: 4px;
    border: 1px solid #eee;
}

.sqb-feedback {
    margin-top: 15px;
    padding: 12px;
    background: #e6fffa;
    border-radius: 6px;
    display: none;
}

.review-mode .sqb-opt {
    cursor: default;
}

.sqb-opt.correct {
    background: #f0fff4;
    border-color: #48bb78;
}

.sqb-opt.wrong {
    background: #fff5f5;
    border-color: #f56565;
}

.review-mode .sqb-opt.correct {
    background: #f0fff4;
    border-color: #48bb78;
}

.review-mode .sqb-opt.wrong {
    background: #fff5f5;
    border-color: #f56565;
}

/* Footer */
.sqb-footer {
    padding: 15px;
    background: #f7fafc;
    border-top: 1px solid #edf2f7;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sqb-btn {
    padding: 10px 0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: white;
    font-weight: bold;
    flex: 1;
    min-height: 40px;
    min-width: 90px;
    white-space: nowrap;
    text-align: center;
}

.sqb-btn-review {
    white-space: nowrap;
    min-width: 140px;
}

.sqb-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sqb-btn-next {
    background: #3182ce;
    flex: 2;
}

.sqb-btn-prev {
    background: #a0aec0;
    flex: 1;
}

.sqb-btn-flag {
    background: transparent;
    border: 1px solid #ed8936;
    color: #ed8936;
    flex: 0 0 auto;
    padding: 10px 15px;
    min-width: 50px;
    white-space: nowrap;
}

.sqb-btn-flag.active {
    background: #ed8936;
    color: white;
}

/* Disable pseudo content to avoid duplicate flag icon in narrow layouts */
.sqb-btn-flag::after {
    content: none;
}

.sqb-btn-submit {
    background: #48bb78;
    flex: 2;
}

.sqb-btn-exit {
    background: #e53e3e;
    flex: 2;
}

/* Result Screen */
.sqb-res-box {
    text-align: center;
    padding: 30px 20px;
}

.sqb-score-lg {
    font-size: 3em;
    font-weight: bold;
    color: #3182ce;
    margin: 15px 0;
}

.sqb-res-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 25px;
    flex-wrap: wrap;
}

.sqb-res-btn {
    padding: 10px 25px;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-weight: bold;
    flex: 1;
    min-width: 120px;
}

/* RTL Support */
[dir="rtl"] .sqb-opt-circle {
    margin-inline-start: 10px;
    margin-inline-end: 0;
}

[dir="rtl"] .sqb-opt-img {
    margin-inline-end: 10px;
    margin-inline-start: 0;
}

[dir="rtl"] .sqb-passage {
    border-right: none;
    border-left: 4px solid #ed8936;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sqb-v10-wrapper {
        border-radius: 0;
        margin: 0;
        border: none;
    }
    
    .sqb-screen {
        padding: 10px;
    }
    
    .sqb-footer {
        flex-direction: column;
        padding: 10px;
    }
    
    .sqb-footer .sqb-btn {
        width: 100%;
        margin-bottom: 5px;
        padding: 12px 0;
        font-size: 16px;
    }
    
    .sqb-btn-top-action,
    .sqb-btn-review,
    .sqb-btn-retry,
    .sqb-btn-submit,
    .sqb-btn-exit {
        width: auto;
    }
    
    .sqb-opt {
        padding: 15px;
        margin-bottom: 10px;
        font-size: 16px; /* منع zoom في iOS */
        align-items: flex-start;
    }
    
    .sqb-opt-circle {
        width: 24px;
        height: 24px;
        margin-inline-end: 15px;
        margin-top: 2px;
    }
    
    .sqb-opt-img {
        margin-top: 10px;
        max-width: 100%;
        height: auto;
    }
    
    .sqb-passage {
        font-size: 14px;
        padding: 10px;
    }
    
    .sqb-q-text {
        font-size: 1em;
    }
    
    .sqb-btn-flag span {
        display: none;
    }
    
    .sqb-btn-flag::after {
        content: none;
    }
    
    .sqb-grid {
        max-height: none;
        padding: 5px;
        overflow-y: visible;
        justify-content: flex-start;
    }
    
    .sqb-grid-item {
        width: 28px;
        min-width: 28px;
        height: 28px;
        font-size: 11px;
    }
    
    .sqb-tabs {
        font-size: 14px;
    }
    
    .sqb-tab {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .sqb-top-header {
        padding: 10px;
        font-size: 14px;
    }
    
    .sqb-res-box {
        padding: 20px 10px;
    }
    
    .sqb-result-details {
        max-width: 100%;
        margin: 20px 0;
    }
}

.sqb-top-header {
    background: #2d3748;
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.sqb-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.sqb-quiz-title {
    font-size: 1rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.sqb-timer-badge {
    background: rgba(255,255,255,0.12);
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 62px;
}

.sqb-analysis-wrapper h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    line-height: 1.4;
    word-break: break-word;
}

/* أنماط التحليل */
.sqb-analysis-wrapper {
    max-width: 100%;
    margin: 20px auto;
    font-family: 'Tajawal', sans-serif;
}
.sqb-skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 20px;
}
.sqb-skill-card {
    min-height: 160px;
    overflow: visible;
}

@media (max-width: 768px) {
    .sqb-skills-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}
.sqb-skill-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
    transition: transform 0.2s;
}
.sqb-skill-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}
.sqb-skill-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}
.sqb-skill-name {
    font-weight: bold;
    font-size: 1.1em;
    color: #2c3e50;
}
.sqb-key-badge {
    font-size: 1.2em;
    background: #f1c40f;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sqb-skill-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    color: #7f8c8d;
}
.sqb-progress-bar {
    height: 8px;
    background: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 15px;
}
.sqb-progress-fill {
    height: 100%;
    background: #3498db;
    border-radius: 4px;
    transition: width 0.3s;
}
.sqb-skill-rating {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sqb-rating-label {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: bold;
}
.sqb-rating-excellent {
    background: #d4edda;
    color: #155724;
}
.sqb-rating-good {
    background: #fff3cd;
    color: #856404;
}
.sqb-rating-weak {
    background: #f8d7da;
    color: #721c24;
}
.sqb-explanation-link {
    background: #3498db;
    color: #fff;
    padding: 5px 12px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9em;
}
.sqb-explanation-link:hover {
    background: #2980b9;
    color: #fff;
}
.sqb-btn-analysis {
    background: #9b59b6;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 1em;
    transition: 0.2s;
}
.sqb-btn-analysis:hover {
    background: #8e44ad;
    transform: scale(1.05);
}
.sqb-top-header {
    background: #2d3748;
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}