/* Question AI Integration Styles - Mobile First Full Width Compact Design */

/* === Main Generator Box === */
#qai-generator {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 16px;
    background: linear-gradient(135deg, #4a6cf7, #3e97ff);
    border-radius: 0;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

/* === Form Styles === */
.qai-form-group {
    margin-bottom: 16px;
    position: relative;
}

.qai-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #f0f0f0;
    font-size: 13px;
    line-height: 1.3;
}

.qai-form-group select,
.qai-form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: #ffffff;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    min-height: 46px;
}

.qai-form-group select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding-right: 36px;
}

.qai-form-group select:focus,
.qai-form-group input:focus {
    border-color: linear-gradient(135deg, #fc4a1a, #f7b733);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
    background-color: #f8fdff;
}

/* === Generate Button === */
#qai-generate-btn {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 9999 !important;
    background: linear-gradient(135deg, #fc4a1a, #f7b733) !important;
    color: #fff !important;
    border: none !important;
    padding: 14px 20px !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    min-height: 44px;
    box-shadow: 0 1px 2px rgba(0, 124, 186, 0.3);
    margin-top: 8px;
}

#qai-generate-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #e03a0a, #e5a329) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 124, 186, 0.4);
}

#qai-generate-btn:disabled {
    background: #b0b0b0 !important;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* === Results Section === */
#qai-results {
    margin-top: 20px;
    padding: 16px;
    background: white;
    border-radius: 0;
    border: 1px solid #e1e1e1;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* === Summary === */
.qai-summary {
    background: #e8f4f8;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    border-left: 3px solid #007cba;
}

.qai-summary p {
    margin: 4px 0;
    color: #333;
    font-size: 12px;
    line-height: 1.4;
}

/* === Questions List === */
.qai-questions-list {
    margin-top: 16px;
    width: 100%;
    box-sizing: border-box;
}

.qai-question-item {
    background: white;
    padding: 14px;
    margin: 12px 0;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    width: 100%;
    box-sizing: border-box;
}

.qai-question-item h4 {
    margin: 0 0 8px 0;
    color: #007cba;
    font-size: 14px;
    font-weight: 600;
}

.question-text {
    font-weight: 500;
    margin-bottom: 12px;
    color: #333;
    line-height: 1.5;
    font-size: 13px;
}

.options-list {
    margin-left: 0;
    padding: 0;
}

.option {
    padding: 8px 10px;
    margin: 6px 0;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #6c757d;
}

.option.correct {
    background: #e8f5e8;
    border-left-color: #28a745;
}

.option-label {
    font-weight: 600;
    color: #495057;
    font-size: 12px;
}

.option-text {
    color: #333;
    font-size: 13px;
    line-height: 1.4;
}

.correct-badge {
    background: #28a745;
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    margin-left: 6px;
    font-weight: bold;
}

/* === Usage Section === */
#qai-usage {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 16px;
    background: #ffffff;
    border-radius: 0;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

#qai-usage h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.qai-usage-summary {
    background: #e8f4f8;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.qai-usage-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    font-size: 12px;
}

.qai-usage-table th {
    background: #007cba;
    color: white;
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
}

.qai-usage-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 12px;
}

.qai-usage-table tr:last-child td {
    border-bottom: none;
}

.subject-name {
    font-weight: 500;
    color: #333;
    font-size: 12px;
}

.used-count, .remaining-count {
    text-align: center;
    font-weight: 500;
    font-size: 12px;
}

.status {
    text-align: center;
    font-weight: 500;
    padding: 4px 6px;
    border-radius: 8px;
    font-size: 10px;
}

.status-available {
    background: #e8f5e8;
    color: #155724;
}

.status-limit {
    background: #fde8e8;
    color: #721c24;
}

.qai-no-usage {
    text-align: center;
    padding: 20px 16px;
    background: white;
    border-radius: 6px;
}

.qai-no-usage p {
    margin: 8px 0;
    color: #666;
    font-size: 13px;
}

/* === Loading & Error States === */
#qai-loading {
    text-align: center;
    padding: 20px 16px;
    background: #e8f4f8;
    border-radius: 6px;
    margin: 16px 0;
}

#qai-loading p {
    margin: 0;
    color: #007cba;
    font-weight: 500;
    font-size: 13px;
}

.qai-error-message {
    background: #fde8e8;
    color: #721c24;
    padding: 12px;
    border-radius: 6px;
    border-left: 3px solid #dc3545;
    margin: 16px 0;
    font-size: 12px;
    line-height: 1.4;
}

.error {
    color: #dc3545;
    background: #fde8e8;
    padding: 10px 12px;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
    font-size: 12px;
}

/* === Success Messages === */
.qai-success-message {
    background: #e8f5e8;
    color: #155724;
    padding: 12px;
    border-radius: 6px;
    border-left: 3px solid #28a745;
    margin: 16px 0;
    font-size: 12px;
    line-height: 1.4;
}

/* === QUIZ INTERFACE STYLES === */
#qai-quiz-interface {
    width: 100%;
    max-width: none;
    margin: 20px 0;
    padding: 16px;
    background: #ffffff;
    border-radius: 0;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.qai-quiz-header {
    background: linear-gradient(135deg, #4a6cf7, #3e97ff);
    color: white;
    padding: 15px 20px;
    border-radius: 0;
    margin: -16px -16px 16px -16px;
}

.qai-quiz-header h3 {
    margin: 0 0 5px 0;
    color: white;
    font-size: 16px;
}

.qai-quiz-meta {
    font-size: 12px;
    opacity: 0.9;
}

#qai-quiz-container {
    background: white;
    border: none;
    border-radius: 0;
}

/* QUIZ QUESTIONS */
.qai-quiz-question {
    padding: 16px;
    border-bottom: 1px solid #e8e8e8;
    background: white;
}

.qai-quiz-question:last-child {
    border-bottom: none;
}

.qai-quiz-question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.qai-quiz-question-header h4 {
    margin: 0;
    color: #007cba;
    font-size: 14px;
    font-weight: 600;
}

.qai-quiz-question-text {
    font-weight: 500;
    margin-bottom: 15px;
    color: #333;
    line-height: 1.5;
    font-size: 13px;
}

/* QUIZ OPTIONS */
.qai-quiz-options {
    margin-left: 0;
    padding: 0;
}

.qai-quiz-option {
    margin: 8px 0;
}

.qai-quiz-option input[type="radio"] {
    display: inline-block !important;
    margin-right: 10px;
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

.qai-quiz-option label {
    display: flex !important;
    align-items: center;
    padding: 12px 15px;
    background: #f8f9fa;
    border: 2px solid #e1e1e1;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

.qai-quiz-option label:hover {
    background: #e9ecef;
    border-color: #007cba;
}

.qai-quiz-option input[type="radio"]:checked + label {
    background: #e8f4f8;
    border-color: #007cba;
    color: #007cba;
}

.option-letter {
    font-weight: bold;
    margin-right: 10px;
    color: #495057;
    min-width: 20px;
    font-size: 13px;
}

.option-text {
    color: #333;
    font-size: 13px;
    line-height: 1.4;
}

/* QUIZ SUBMIT BUTTON */
.qai-submit-btn {
    background: linear-gradient(135deg, #28a745, #20c997) !important;
    color: white;
    padding: 14px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin: 16px 0;
    width: 100%;
    transition: all 0.3s ease;
    min-height: 44px;
}

.qai-submit-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #218838, #1ba87e) !important;
    transform: translateY(-1px);
}

.qai-submit-btn:disabled {
    background: #6c757d !important;
    cursor: not-allowed;
    transform: none;
}

/* QUIZ RESULTS */
#qai-quiz-results {
    background: white;
    border: none;
    border-radius: 0;
    margin-top: 20px;
    padding: 0;
}

.qai-results-header {
    background: linear-gradient(135deg, #4a6cf7, #3e97ff);
    padding: 15px 20px;
    border-bottom: 1px solid #e1e1e1;
    margin: 0 -16px 16px -16px;
}

.qai-results-header h3 {
    margin: 0;
    color: white;
    font-size: 16px;
}

.qai-results-summary-card {
    padding: 16px;
    background: #f8f9fa;
    margin: 0 0 16px 0;
    border-radius: 0;
}

.qai-results-summary-card h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 15px;
}

.qai-results-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.qai-stat-item {
    text-align: center;
    padding: 12px;
    border-radius: 6px;
    background: white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.correct-stat {
    border-left: 4px solid #28a745;
}

.wrong-stat {
    border-left: 4px solid #dc3545;
}

.score-stat {
    border-left: 4px solid #007cba;
}

.time-stat {
    border-left: 4px solid #6c757d;
}

.stat-value {
    display: block;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 4px;
}

.correct-stat .stat-value { color: #28a745; }
.wrong-stat .stat-value { color: #dc3545; }
.score-stat .stat-value { color: #007cba; }
.time-stat .stat-value { color: #6c757d; }

.stat-label {
    font-size: 11px;
    color: #6c757d;
    text-transform: uppercase;
    font-weight: 600;
}

/* DETAILED RESULTS */
.qai-detailed-results {
    padding: 0;
}

.qai-detailed-results h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 15px;
    padding: 0 16px;
}

.qai-result-item {
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 0;
    border-left: 4px solid #6c757d;
    background: white;
    border-bottom: 1px solid #f0f0f0;
}

.result-correct {
    border-left-color: #28a745;
    background: #f8fff9;
}

.result-wrong {
    border-left-color: #dc3545;
    background: #fff8f8;
}

.result-question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.result-question-header h5 {
    margin: 0;
    color: #333;
    font-size: 14px;
}

.result-status {
    font-weight: 600;
    font-size: 12px;
}

.result-correct .result-status { color: #28a745; }
.result-wrong .result-status { color: #dc3545; }

.result-question-text {
    margin-bottom: 12px;
    color: #333;
    line-height: 1.5;
    font-size: 13px;
}

.result-options {
    margin-left: 0;
    padding: 0;
}

.result-option {
    padding: 10px 12px;
    margin: 6px 0;
    border-radius: 4px;
    border-left: 3px solid #6c757d;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    font-size: 13px;
}

.selected-correct {
    background: #d4edda !important;
    border-left-color: #28a745 !important;
    color: #155724;
}

.selected-wrong {
    background: #f8d7da !important;
    border-left-color: #dc3545 !important;
    color: #721c24;
}

.correct-answer {
    background: #d1ecf1 !important;
    border-left-color: #17a2b8 !important;
    color: #0c5460;
}

.result-indicator {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(0,0,0,0.1);
}

/* NEW QUIZ BUTTON */
.qai-new-quiz-btn {
    background: linear-gradient(135deg, #4a6cf7, #3e97ff) !important;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin: 16px 0;
    transition: all 0.3s ease;
    width: 100%;
    min-height: 44px;
}

.qai-new-quiz-btn:hover {
    background: linear-gradient(135deg, #3955d6, #2d7ed6) !important;
}

/* QUIZ LOADING AND ERROR */
#qai-quiz-loading {
    text-align: center;
    padding: 30px 16px;
    background: #f0f8ff;
    border-radius: 0;
    margin: 16px 0;
}

.qai-no-quiz-message {
    text-align: center;
    padding: 30px 16px;
    background: #f8f9fa;
    border-radius: 0;
    color: #6c757d;
    font-size: 13px;
}

/* PERFORMANCE HISTORY */
.qai-performance-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.qai-performance-stat {
    text-align: center;
    padding: 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e1e1e1;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.qai-performance-stat .stat-value {
    font-size: 16px;
    color: #007cba;
}

.qai-history-table {
    background: white;
    border-radius: 0;
    border: none;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.qai-history-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 2fr;
    gap: 1px;
    background: #007cba;
    color: white;
    font-weight: 600;
    padding: 12px 8px;
    font-size: 11px;
}

.qai-history-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 2fr;
    gap: 1px;
    padding: 10px 8px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 11px;
}

.qai-history-row:last-child {
    border-bottom: none;
}

.qai-history-row:hover {
    background: #f8f9fa;
}

.history-score {
    font-weight: 600;
}

.score-high { color: #28a745; }
.score-medium { color: #ffc107; }
.score-low { color: #dc3545; }

/* === Mobile (<=480px) === */
@media (max-width: 480px) {
    #qai-generator,
    #qai-usage,
    #qai-quiz-interface {
        width: 100%;
        margin: 0;
        padding: 14px;
        border-radius: 0;
    }

    .qai-form-group {
        margin-bottom: 14px;
    }

    .qai-form-group select,
    .qai-form-group input {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 40px;
        border-radius: 5px;
    }

    #qai-generate-btn {
        padding: 12px 16px;
        min-height: 40px;
        font-size: 13px;
        border-radius: 5px;
    }

    .qai-question-item {
        padding: 12px;
        margin: 10px 0;
        border-radius: 6px;
        width: 100%;
    }

    #qai-results {
        padding: 12px;
        margin-top: 16px;
    }

    .qai-results-stats,
    .qai-performance-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .qai-history-header,
    .qai-history-row {
        grid-template-columns: 1fr;
        gap: 5px;
    }
    
    .qai-quiz-option label {
        padding: 10px 12px;
    }
}

/* === Small Mobile (<=360px) === */
@media (max-width: 360px) {
    #qai-generator,
    #qai-usage,
    #qai-quiz-interface {
        width: 100%;
        padding: 12px;
        margin: 0;
    }

    .qai-form-group label {
        font-size: 12px;
    }

    .qai-form-group select,
    .qai-form-group input {
        padding: 8px 10px;
        font-size: 12px;
        min-height: 38px;
    }

    #qai-generate-btn {
        padding: 10px 14px;
        min-height: 38px;
        font-size: 12px;
    }
}

/* === Tablet & Larger Screens === */
@media (min-width: 768px) {
    #qai-generator,
    #qai-usage,
    #qai-quiz-interface {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 18px;
        border-radius: 0;
    }
}

/* === Touch Devices === */
@media (hover: none) and (pointer: coarse) {
    #qai-generate-btn:hover:not(:disabled),
    .qai-submit-btn:hover:not(:disabled),
    .qai-new-quiz-btn:hover {
        transform: none;
        box-shadow: 0 1px 2px rgba(0, 124, 186, 0.3);
    }

    .qai-form-group select,
    .qai-form-group input,
    #qai-generate-btn,
    .qai-submit-btn,
    .qai-new-quiz-btn {
        min-height: 42px;
    }

    .option {
        padding: 10px 12px;
    }
}