/* Custom Popup Styles */
.custom-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100010;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

.custom-popup-overlay.custom-popup-show {
    opacity: 1;
}

.custom-popup-container {
    background: white;
    border-radius: 12px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(-20px);
    transition: transform 0.3s ease;
    position: relative;
    overflow: hidden;
}

.custom-popup-overlay.custom-popup-show .custom-popup-container {
    transform: scale(1) translateY(0);
}

.custom-popup-content {
    padding: 28px 32px;
    display: flex;
    align-items: center;
    gap: 18px;
    position: relative;
}

.custom-popup-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.custom-popup-text {
    flex: 1;
    min-width: 0;
    padding-right: 24px;
}

.custom-popup-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
    display: none;
}

.custom-popup-message {
    font-size: 0.95rem;
    line-height: 1.55;
    color: #475569;
    font-weight: 400;
}

.custom-popup-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.custom-popup-action-btn {
    min-height: 42px;
    border: 1px solid transparent;
    background: #3b82f6;
    color: #ffffff;
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.1;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 10px 22px rgba(59, 130, 246, 0.22);
}

.custom-popup-action-btn:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.custom-popup-action-btn.is-secondary {
    background: #ffffff;
    color: #334155;
    border-color: #cbd5e1;
    box-shadow: none;
}

.custom-popup-action-btn.is-secondary:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
}

.custom-popup-action-btn.is-danger {
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
    box-shadow: 0 10px 22px rgba(220, 38, 38, 0.22);
}

.custom-popup-action-btn.is-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.custom-popup-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.custom-popup-close:hover {
    background: #f1f5f9;
    color: #1e293b;
}

/* Type-specific styles */
.custom-popup-success {
    border-top: 4px solid #10b981;
}

.custom-popup-success .custom-popup-icon {
    color: #10b981;
}

.custom-popup-error {
    border-top: 4px solid #ef4444;
}

.custom-popup-error .custom-popup-icon {
    color: #ef4444;
}

.custom-popup-warning {
    border-top: 4px solid #f59e0b;
}

.custom-popup-warning .custom-popup-icon {
    color: #f59e0b;
}

.custom-popup-info {
    border-top: 4px solid #3b82f6;
}

.custom-popup-info .custom-popup-icon {
    color: #3b82f6;
}

.custom-popup-container.writing-quit-confirm,
.custom-popup-container.writing-submit-confirm {
    max-width: 560px;
    border-top: 4px solid #3b82f6;
}

.custom-popup-container.writing-quit-confirm .custom-popup-content,
.custom-popup-container.writing-submit-confirm .custom-popup-content {
    align-items: flex-start;
}

.custom-popup-container.writing-quit-confirm .custom-popup-actions,
.custom-popup-container.writing-submit-confirm .custom-popup-actions {
    margin-top: 18px !important;
}

.custom-popup-container.cheat-events-popup {
    max-width: 760px;
    max-height: min(88vh, 820px);
    border-top: 4px solid #3b82f6;
    background:
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.12), transparent 34%),
        linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    display: flex;
    flex-direction: column;
}

.custom-popup-container.cheat-events-popup .custom-popup-content {
    align-items: flex-start;
    gap: 0;
    padding: 28px 32px 30px;
    min-height: 0;
    overflow: hidden;
}

.custom-popup-container.cheat-events-popup .custom-popup-icon {
    display: none;
}

.custom-popup-container.cheat-events-popup .custom-popup-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    padding-right: 12px;
}

.custom-popup-container.cheat-events-popup .custom-popup-title {
    display: block;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.custom-popup-container.cheat-events-popup .custom-popup-message {
    color: #334155;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.custom-popup-container.class-delete-error-popup {
    max-width: 560px;
    border: 1px solid rgba(239, 68, 68, 0.18);
    border-top: 4px solid #ef4444;
    background:
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.14), transparent 35%),
        linear-gradient(180deg, #ffffff 0%, #fff7f7 100%);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
}

.custom-popup-container.class-delete-error-popup .custom-popup-content {
    align-items: flex-start;
    padding: 28px 32px 30px;
}

.custom-popup-container.class-delete-error-popup .custom-popup-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #ef4444;
    background: linear-gradient(135deg, #fee2e2 0%, #ffffff 100%);
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.1);
}

.custom-popup-container.class-delete-error-popup .custom-popup-text {
    padding-right: 16px;
}

.custom-popup-container.class-delete-error-popup .custom-popup-title {
    display: block;
    margin-bottom: 0.45rem;
    color: #991b1b;
}

.custom-popup-container.class-delete-error-popup .custom-popup-message {
    color: #334155;
}

.custom-popup-container.class-delete-error-popup .custom-popup-close:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
}

.custom-popup-container.classroom-import-popup {
    max-width: 900px;
    width: min(920px, 95vw);
    max-height: min(92vh, 860px);
    border-top: 4px solid #3b82f6;
}

.custom-popup-container.classroom-import-popup .custom-popup-content {
    align-items: flex-start;
    gap: 16px;
    padding: 30px 32px 30px;
    max-height: min(92vh, 860px);
}

.custom-popup-container.classroom-import-popup .custom-popup-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.custom-popup-container.classroom-import-popup .custom-popup-text {
    min-width: 0;
    overflow: hidden;
}

.custom-popup-container.classroom-import-popup .custom-popup-title {
    display: block;
    font-size: 1.25rem;
    margin-bottom: 0.6rem;
}

.custom-popup-container.classroom-import-popup .custom-popup-message {
    color: #334155;
    display: block;
}

.custom-popup-container.classroom-import-popup .custom-popup-actions {
    margin-top: 8px;
    width: 100%;
    justify-content: flex-end;
}

.custom-popup-container.classroom-import-popup .profile-classroom-import-popup-row {
    display: block;
}

.custom-popup-container.classroom-import-popup .profile-classroom-import-popup-row-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    cursor: pointer;
    list-style: none;
}

.custom-popup-container.classroom-import-popup .profile-classroom-import-popup-row-summary::-webkit-details-marker {
    display: none;
}

.custom-popup-container.classroom-import-popup .profile-classroom-import-popup-row-summary::marker {
    content: "";
}

.custom-popup-container.classroom-import-popup .profile-classroom-import-popup-toggle {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #3b82f6;
    font-size: 0.84rem;
    font-weight: 700;
    line-height: 1;
}

.custom-popup-container.classroom-import-popup .profile-classroom-import-popup-toggle i {
    font-size: 0.78rem;
    transition: transform 0.2s ease;
}

.custom-popup-container.classroom-import-popup .profile-classroom-import-popup-row[open] .profile-classroom-import-popup-toggle i {
    transform: rotate(180deg);
}

.custom-popup-container.classroom-import-popup .profile-classroom-import-popup-row[open] .profile-classroom-import-popup-course-controls {
    margin-top: 12px;
}

.custom-popup-container.classroom-import-popup .profile-classroom-import-popup-course {
    min-width: 0;
}

.custom-popup-container.classroom-import-popup .profile-classroom-import-check {
    min-width: 0;
}

.custom-popup-container.classroom-import-popup .profile-classroom-import-check > span {
    min-width: 0;
}

/* Mobile responsive */
@media (max-width: 640px) {
    .custom-popup-container {
        width: 95%;
        margin: 20px;
    }

    .custom-popup-container.cheat-events-popup .custom-popup-content {
        padding: 22px 20px 24px;
    }

    .custom-popup-content {
        padding: 20px 20px;
    }

    .custom-popup-icon {
        font-size: 26px;
    }

    .custom-popup-title {
        font-size: 1rem;
    }

    .custom-popup-message {
        font-size: 0.9rem;
    }

    .custom-popup-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .custom-popup-action-btn {
        width: 100%;
    }
}

/* Animation for multiple popups */
@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.generation-popup-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.generation-popup-modal.hidden {
    display: none;
}

.generation-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.generation-popup-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: popupSlideIn 0.3s ease;
}

.generation-popup-icon {
    font-size: 48px;
    color: #3b82f6;
    margin-bottom: 20px;
}

.generation-popup-content h2 {
    margin: 0 0 12px;
    font-size: 1.5rem;
    color: #1f2937;
}

.generation-popup-content p {
    margin: 0 0 20px;
    color: #6b7280;
    font-size: 1rem;
    line-height: 1.6;
}

.generation-popup-recommendation {
    margin-top: 1.25rem;
    padding: 1rem 1.1rem;
    border: 1px solid rgba(59, 130, 246, 0.18);
    border-radius: 12px;
    background: #eff6ff;
    text-align: left;
}

.generation-popup-recommendation.hidden {
    display: none;
}

.generation-popup-recommendation-label {
    margin-bottom: 0.4rem;
    color: #1d4ed8;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.generation-popup-recommendation-text {
    margin: 0;
    color: #1e3a8a;
    font-size: 0.95rem;
    line-height: 1.65;
    white-space: pre-wrap;
}

.generation-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.generation-popup-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.generation-popup-progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 10px;
}

.generation-popup-progress-fill {
    width: 0;
    height: 100%;
    background: #3b82f6;
    border-radius: inherit;
    transition: width 0.3s ease;
}

.generation-popup-progress-fill.is-indeterminate {
    width: 100%;
    animation: scolaroLoadingPulse 1.2s ease-in-out infinite;
}

.clarification-info-animate {
    animation: clarificationInfoPop 0.28s ease;
}

@keyframes scolaroLoadingPulse {
    0% {
        opacity: 0.55;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.55;
    }
}

@keyframes clarificationInfoPop {
    0% {
        opacity: 0;
        transform: translateY(4px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 640px) {
    .generation-popup-content {
        width: 95%;
        padding: 28px 22px;
    }

    .generation-popup-icon {
        font-size: 42px;
    }
}

/* Cheating Modal Styles */
.cheating-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    backdrop-filter: blur(4px);
}

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

.cheating-modal-content {
    background: white;
    border-radius: 12px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
    animation: cheatingModalSlideIn 0.3s ease;
}

@keyframes cheatingModalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.cheating-modal-header {
    padding: 24px 32px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cheating-student-notice .cheating-modal-content {
    max-width: 500px;
}

.cheating-student-notice .cheating-modal-header {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.cheating-student-notice .cheating-modal-body {
    background: #fff;
}

.cheating-modal-header i {
    font-size: 28px;
}

.cheating-modal-header h2 {
    flex: 1;
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.cheating-modal-close-button {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    transition: background 0.2s ease, transform 0.2s ease;
}

.cheating-modal-close-button:hover {
    background: rgba(255, 255, 255, 0.26);
    transform: translateY(-1px);
}

.cheating-modal-close-button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.cheating-modal-body {
    padding: 24px 32px;
    color: #1f2937;
    line-height: 1.6;
}

.cheating-modal-body p {
    margin: 0 0 12px 0;
}

.cheating-modal-body p:last-child {
    margin-bottom: 0;
}

.cheating-modal-refresh-button {
    appearance: none;
    background: transparent;
    border: 0;
    color: #3b82f6;
    cursor: pointer;
    display: inline;
    font: inherit;
    margin: 0;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cheating-modal-refresh-button:hover {
    color: #2563eb;
}

.cheating-modal-refresh-button:focus-visible {
    border-radius: 4px;
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.cheating-modal-footer {
    padding: 20px 32px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.cheating-modal-footer.teacher-footer {
    justify-content: space-between;
}

.cheating-modal-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-size: 0.9rem;
}

.cheating-modal-footer .btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

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

.cheating-modal-footer .btn-danger {
    background: #ef4444;
    color: white;
}

.cheating-modal-footer .btn-danger:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-1px);
}

.cheating-modal-footer .btn-primary {
    background: #3b82f6;
    color: white;
}

.cheating-modal-footer .btn-primary:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-1px);
}

.cheating-modal-footer .btn .btn-text {
    display: inline;
}

.cheating-modal-footer .btn .btn-loading {
    display: none;
    align-items: center;
    gap: 8px;
}

.cheating-modal-footer .btn[data-loading="true"] .btn-text {
    display: none;
}

.cheating-modal-footer .btn[data-loading="true"] .btn-loading {
    display: inline-flex;
}

.cheating-modal-content.teacher-modal .cheating-modal-header {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

/* Mobile responsive */
@media (max-width: 640px) {
    .cheating-modal-content {
        width: 95%;
        margin: 20px;
    }

    .cheating-modal-header,
    .cheating-modal-body,
    .cheating-modal-footer {
        padding: 20px 24px;
    }

    .cheating-modal-header h2 {
        font-size: 1.25rem;
    }

    .cheating-modal-footer {
        flex-direction: column;
    }

    .cheating-modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
}
