/* ================= MODAL BACKDROP ================= */
#analysis-modal.sub-modal-backdrop {
    display: none;
    position: fixed !important;
    inset: 0 !important;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    z-index: 999999 !important;

    align-items: center !important;
    justify-content: center !important;
    padding: 24px;
}

#analysis-modal.sub-modal-backdrop.open {
    display: flex !important;
}

/* ================= CARD ================= */
.sub-modal-card {
    background: #ffffff;
    border-radius: 20px;
    max-width: 820px;
    width: 100%;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
    position: relative;
    overflow: hidden;
}

/* ================= LAYOUT ================= */
.sub-modal-layout {
    display: grid;
    grid-template-columns: 1fr 1.35fr;
    min-height: 480px;
}

/* ================= LEFT ================= */
.sub-modal-left {
    background: linear-gradient(150deg, #4f46e5, #7c3aed);
    padding: 32px;
    color: #fff;
}

.sub-modal-left-heading {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.sub-modal-left-sub {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* ================= SCORE ================= */
.analysis-score-block {
    margin-top: 30px;
    text-align: center;
}

.analysis-score-value {
    font-size: 2.4rem;
    font-weight: 800;
    color: #fff;
}

.analysis-score-label {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.7);
}

/* ================= RIGHT ================= */
.sub-modal-right {
    padding: 28px;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: auto;
    max-height: 450px;
}

/* CLOSE BUTTON */
.sub-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
}

/* ================= CONTENT ================= */
.analysis-content {
    margin-top: 20px;
}

/* ================= SUMMARY ================= */
.analysis-summary {
    font-size: 0.9rem;
    color: #475569;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* ================= LINES ================= */
.analysis-lines {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.analysis-line {
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    border: 1px solid #e2e8f0;
}

.analysis-line.ai-line {
    background: #fff1f2;
    border-color: #fecaca;
}

.analysis-line.human-line {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.analysis-line-text {
    margin-bottom: 6px;
    color: #0f172a;
}

.analysis-line-meta {
    font-size: 0.7rem;
    display: flex;
    gap: 10px;
    color: #64748b;
}

/* ================= LOADING ================= */
.sub-modal-loading {
    text-align: center;
    padding: 40px 0;
}

.sub-modal-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 10px;
}

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

/* ================= STATES ================= */
.analysis-error {
    text-align: center;
    color: #ef4444;
    font-size: 0.9rem;
}

.analysis-loading-state {
    text-align: center;
    padding: 30px;
}

/* ================= MOBILE ================= */
@media (max-width: 600px) {
    #analysis-modal.sub-modal-backdrop {
        padding: 14px;
        align-items: center !important;
    }

    .sub-modal-card {
        border-radius: 16px;
        max-height: 88vh;
        overflow: hidden;
        position: relative;
        animation: modalFadeIn 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    }

    @keyframes modalFadeIn {
        from { transform: scale(0.96); opacity: 0; }
        to { transform: scale(1); opacity: 1; }
    }

    .sub-modal-layout {
        grid-template-columns: 1fr;
        min-height: auto;
        display: flex;
        flex-direction: column;
        max-height: 88vh;
    }

    .sub-modal-left {
        padding: 18px 20px 14px;
        flex-shrink: 0;
    }

    .sub-modal-left-heading {
        font-size: 1.15rem !important;
        margin-bottom: 2px !important;
    }

    .sub-modal-left-sub {
        font-size: 0.75rem !important;
    }

    .analysis-score-block {
        margin-top: 12px !important;
        text-align: center;
    }

    .analysis-score-value {
        font-size: 1.8rem !important;
    }

    .analysis-score-label {
        font-size: 0.68rem !important;
    }

    #analysis-verdict {
        font-size: 0.82rem;
        text-align: center;
    }

    .sub-modal-close {
        position: absolute;
        top: 14px;
        right: 14px;
        z-index: 10;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.25);
        border: 1px solid rgba(255, 255, 255, 0.35);
        color: #fff;
        font-size: 1rem;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    .sub-modal-right {
        padding: 18px 16px 22px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: none;
        flex: 1;
        min-height: 0;
        position: static;
    }

    .analysis-content {
        margin-top: 8px;
    }

    .analysis-sentences {
        padding-right: 0;
        gap: 14px;
        padding-bottom: 10px;
    }

    .analysis-sentence {
        padding: 14px 14px;
        border-radius: 10px;
        gap: 10px;
    }

    .analysis-sentence-text {
        font-size: 13.5px !important;
        line-height: 1.55 !important;
    }

    .analysis-sentence-reason {
        font-size: 12.5px !important;
        line-height: 1.5 !important;
    }

    .analysis-summary {
        margin-bottom: 20px;
    }

    .analysis-summary ul {
        padding-left: 18px;
    }

    .analysis-summary li {
        font-size: 0.84rem;
        margin-bottom: 8px;
        line-height: 1.55;
    }
}

/* Container */
.analysis-sentences {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 6px;
}

/* Each sentence card */
.analysis-sentence {
    background: #ffffff;
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-left: 5px solid #ccc;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Hover effect */
.analysis-sentence:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

/* Sentence text */
.analysis-sentence-text {
    font-size: 15px;
    font-weight: 500;
    color: #222;
    line-height: 1.5;
}

/* Label (AI / HUMAN) */
.analysis-sentence-label {
    width: fit-content;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* AI label */
.analysis-sentence-label:contains("AI") {
    background: #ffe5e5;
    color: #d93025;
}

/* HUMAN label */
.analysis-sentence-label:contains("HUMAN") {
    background: #e6f4ea;
    color: #1e8e3e;
}

/* Confidence */
.analysis-sentence-confidence {
    font-size: 13px;
    color: #555;
}

/* Pattern */
.analysis-sentence-pattern {
    font-size: 12px;
    font-weight: 600;
    color: #4a6cf7;
    background: #eef2ff;
    padding: 3px 8px;
    border-radius: 6px;
    width: fit-content;
}

/* Reason */
.analysis-sentence-reason {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    border-top: 1px dashed #eee;
    padding-top: 6px;
}