/* =========================================
   CRM Exams Engine - Ultimate Modern UI
   ========================================= */

:root {
    /* Color Palette */
    --crm-primary: #2271b1;       /* WordPress Blue */
    --crm-primary-dark: #135e96;
    --crm-accent: #72aee6;
    --crm-success: #00a32a;
    --crm-warning: #f0c33c;
    --crm-danger: #d63638;
    --crm-text-main: #1d2327;
    --crm-text-light: #646970;
    --crm-bg-light: #f6f7f7;
    --crm-bg-white: #ffffff;
    --crm-border: #c3c4c7;
    --crm-border-light: #dcdcde;
    
    /* Spacing & Layout */
    --crm-radius: 8px;
    --crm-radius-sm: 4px;
    --crm-shadow-sm: 0 2px 5px rgba(0,0,0,0.05);
    --crm-shadow-md: 0 5px 15px rgba(0,0,0,0.08);
    --crm-shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --crm-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Global Container --- */
.wrap.crm-exam-builder {
    max-width: 1000px;
    margin: 30px auto 80px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Page Title & Global Actions */
.wrap.crm-exam-builder h1 {
    font-weight: 700;
    color: var(--crm-text-main);
    font-size: 24px;
}

.global-actions {
    display: flex;
    gap: 10px;
}

.global-actions .button {
    border-radius: 20px;
    padding: 0 15px;
    font-size: 13px;
    border-color: var(--crm-border);
    color: var(--crm-text-light);
    transition: var(--crm-transition);
}

.global-actions .button:hover {
    border-color: var(--crm-primary);
    color: var(--crm-primary);
    background: #f0f6fc;
}

/* --- Postbox / Cards General --- */
.postbox, .crm-section-box {
    border: none !important;
    box-shadow: var(--crm-shadow-sm);
    border-radius: var(--crm-radius);
    background: var(--crm-bg-white);
    overflow: hidden;
    margin-bottom: 30px;
    transition: var(--crm-transition);
}

.crm-section-box:hover {
    box-shadow: var(--crm-shadow-md);
    transform: translateY(-2px);
}

/* Headers (Toggle Triggers) */
.postbox-header, .group-header, .q-header {
    user-select: none;
    transition: background 0.2s;
}

.postbox-header {
    background: linear-gradient(to right, #fbfbfb, #fff);
    border-bottom: 1px solid var(--crm-border-light);
    padding: 15px 20px;
}

.postbox-header:hover {
    background: #f0f6fc;
}

.hndle {
    font-size: 16px !important;
    color: var(--crm-text-main) !important;
    display: flex;
    align-items: center;
}

/* Icons styling */
.toggle-icon {
    color: var(--crm-text-light);
    transition: transform 0.2s;
    font-size: 18px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.postbox-header:hover .toggle-icon {
    background: rgba(0,0,0,0.05);
    color: var(--crm-primary);
}

.dashicons-category {
    color: var(--crm-primary);
    background: rgba(34, 113, 177, 0.1);
    padding: 6px;
    border-radius: 6px;
    margin-right: 10px !important;
}

/* --- Content Areas --- */
.inside, .section-content {
    padding: 25px;
}

/* Inputs */
input[type="text"], textarea, select {
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-sm);
    padding: 8px 12px;
    font-size: 14px;
    color: var(--crm-text-main);
    box-shadow: none !important;
    transition: var(--crm-transition);
}

input[type="text"]:focus, textarea:focus, select:focus {
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2) !important;
}

.sec-name-input {
    font-size: 18px !important;
    font-weight: 600;
    padding: 10px !important;
    background: #fafafa;
}

/* --- Group Boxes (Passage/Media) --- */
.crm-group-box {
    border: 1px solid var(--crm-border-light);
    border-radius: var(--crm-radius);
    margin-bottom: 25px;
    overflow: hidden;
    position: relative;
    background: var(--crm-bg-white);
}

/* Color Coding for Groups */
.crm-group-box[style*="border-left:4px solid #00a32a"] { /* Text */
    border-left: 4px solid var(--crm-success) !important;
}
.crm-group-box[style*="border-left:4px solid #d63638"] { /* Media */
    border-left: 4px solid var(--crm-danger) !important;
}

.group-header {
    background: #fcfcfc;
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f1;
}

.group-header strong {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--crm-text-light);
}

.group-content-area {
    background: #fbfbfb;
    padding: 20px;
    border-bottom: 1px dashed var(--crm-border-light);
}

/* Sub-questions indentation container */
.sub-questions-wrapper {
    background: var(--crm-bg-white);
    padding: 20px 20px 20px 35px;
    position: relative;
}

/* Hierarchy Line */
.sub-questions-wrapper::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 20px;
    bottom: 20px;
    width: 2px;
    background: #eee;
    border-radius: 2px;
}

/* --- Question Item --- */
.crm-question-item {
    background: var(--crm-bg-white);
    border: 1px solid var(--crm-border-light);
    border-radius: var(--crm-radius);
    padding: 20px;
    margin-bottom: 15px;
    position: relative;
    transition: var(--crm-transition);
}

/* Single Question Card */
.crm-question-item.is-single {
    border-left: 4px solid var(--crm-primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

/* Sub Question Card */
.crm-question-item.is-sub {
    border-left: 4px solid var(--crm-text-light);
    box-shadow: none;
    background: #fcfcfc;
    margin-left: 5px; /* Slight offset from the hierarchy line */
}

/* Hover Effect */
.crm-question-item:hover {
    border-color: #b0b0b0;
    box-shadow: var(--crm-shadow-sm);
}

.q-header {
    border-bottom: 1px solid transparent;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.crm-question-item.is-single .q-header strong {
    color: var(--crm-primary-dark);
}

/* Question Inputs */
.q-type-select {
    min-width: 220px;
    background-color: #fbfbfb;
}

textarea {
    line-height: 1.5;
    resize: vertical;
}

/* Instructions Label */
label[style*="font-size:11px"] {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: block;
}

/* Helper Bubble for [blank] */
.type-desc {
    background: #fff8e5;
    color: #8a6d3b;
    border: 1px solid #faebcc;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    display: inline-block;
    margin-top: 5px;
}
.type-desc b {
    background: rgba(255,255,255,0.5);
    padding: 0 4px;
    border-radius: 3px;
    border: 1px dashed #8a6d3b;
}

/* --- Choices Area --- */
.q-choices-area {
    background: #fcfcfc;
    border: 1px solid #f0f0f1;
    border-radius: var(--crm-radius-sm);
    padding: 15px;
    margin-top: 15px;
}

.choices-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--crm-text-light);
    margin-bottom: 10px;
    display: block;
}

.choices-list {
    margin: 0;
}

.choice-line {
    display: flex;
    align-items: center;
    background: var(--crm-bg-white);
    border: 1px solid var(--crm-border-light);
    border-radius: var(--crm-radius-sm);
    padding: 8px 12px;
    margin-bottom: 8px;
    transition: border-color 0.2s;
}

.choice-line:focus-within {
    border-color: var(--crm-primary);
    background: #fbfdff;
}

.choice-line input[type="text"] {
    border: none;
    background: transparent;
    padding: 0 10px;
    font-size: 14px;
    width: 100%;
}

.choice-line input[type="text"]:focus {
    box-shadow: none !important;
}

/* Delete Buttons (X) */
.remove-choice-btn, .button-link-delete {
    cursor: pointer;
    transition: var(--crm-transition);
}

.remove-choice-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--crm-danger);
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-choice-btn:hover {
    background: var(--crm-danger);
    color: #fff;
    border-color: var(--crm-danger);
}

/* --- Add Toolbar --- */
.add-toolbar {
    background: #fafafa;
    border-top: 1px dashed var(--crm-border-light);
    padding: 15px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.add-toolbar .button {
    background: var(--crm-bg-white);
    border: 1px solid var(--crm-border-light);
    color: var(--crm-text-light);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 15px;
    height: auto;
    border-radius: 20px;
    transition: var(--crm-transition);
}

.add-toolbar .button:hover {
    color: var(--crm-primary);
    border-color: var(--crm-primary);
    background: #f0f6fc;
    transform: translateY(-1px);
}

/* Specific Add Button Colors */
.add-single-btn:hover { color: var(--crm-primary); border-color: var(--crm-primary); }
.add-group-text-btn:hover { color: var(--crm-success); border-color: var(--crm-success); }
.add-group-media-btn:hover { color: var(--crm-danger); border-color: var(--crm-danger); }

/* Add Sub/Choice small buttons */
.add-sub-btn, .add-choice-btn {
    border: 1px dashed var(--crm-border) !important;
    background: transparent !important;
    color: var(--crm-text-light) !important;
    font-size: 12px !important;
    border-radius: 4px !important;
}
.add-sub-btn:hover, .add-choice-btn:hover {
    border-color: var(--crm-primary) !important;
    color: var(--crm-primary) !important;
    background: #f0f6fc !important;
}

/* Big Add Section Button */
#add-section-btn {
    display: block;
    margin: 40px auto 20px;
    padding: 12px 30px;
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--crm-primary);
    border: none;
    color: #fff;
    border-radius: 50px;
    box-shadow: 0 4px 10px rgba(34, 113, 177, 0.3);
    transition: var(--crm-transition);
    cursor: pointer;
}

#add-section-btn:hover {
    background: var(--crm-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(34, 113, 177, 0.4);
}

/* Sticky Footer */
.sticky-footer {
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid var(--crm-border);
    padding: 20px;
    position: sticky;
    bottom: 0;
    z-index: 999;
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: flex-end;
    box-shadow: 0 -5px 10px rgba(0,0,0,0.03);
    margin: 0 -20px -20px -20px; /* Stretch to edges in some views */
}

/* --- Results / Grading Page Specifics (Future Proofing) --- */
.crm-result-card {
    background: #fff;
    border-radius: var(--crm-radius);
    padding: 20px;
    box-shadow: var(--crm-shadow-sm);
    margin-bottom: 20px;
}

.crm-score-box {
    text-align: center;
    padding: 15px;
    border-radius: var(--crm-radius);
    background: #f9f9f9;
    border: 1px solid #eee;
}
.crm-score-val {
    font-size: 32px;
    font-weight: 800;
    color: var(--crm-primary);
    line-height: 1.2;
}
.crm-score-label {
    font-size: 12px;
    text-transform: uppercase;
    color: #777;
}

/* Responsive */
@media screen and (max-width: 782px) {
    .crm-section-box .postbox-header, .add-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .global-actions {
        display: none; /* Simplify on mobile */
    }
    .sub-questions-wrapper {
        padding-left: 15px;
    }
}

/* --- RESULT PAGE MODERN DESIGN --- */

/* Header */
.crm-res-header { text-align: center; margin-bottom: 40px; }
.crm-res-title { font-size: 2.5rem; color: #2c3e50; font-weight: 800; line-height: 1.2; }
.crm-res-title span { color: #3498db; }

/* Grid Layout */
.crm-res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; align-items: start; }
@media (max-width: 768px) { .crm-res-grid { grid-template-columns: 1fr; } }

/* Cards Common */
.crm-res-card { background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.08); padding: 30px; margin-bottom: 30px; transition: transform 0.3s ease; border: 1px solid rgba(0,0,0,0.02); }
.crm-res-card:hover { transform: translateY(-5px); }
.crm-res-card h3 { margin-top: 0; margin-bottom: 20px; font-size: 1.2rem; color: #7f8c8d; text-transform: uppercase; letter-spacing: 1px; border-bottom: 2px solid #f0f2f5; padding-bottom: 10px; }

/* Box 1: Score & Level */
.crm-main-score-card { display: flex; align-items: center; gap: 30px; background: linear-gradient(135deg, #ffffff 0%, #f9fbfd 100%); }
.crm-score-circle { width: 120px; height: 120px; border-radius: 50%; background: #fff; border: 8px solid #2ecc71; display: flex; flex-direction: column; justify-content: center; align-items: center; box-shadow: 0 5px 15px rgba(46, 204, 113, 0.3); flex-shrink: 0; }
.crm-score-circle span { font-size: 2.2rem; font-weight: 900; color: #2c3e50; line-height: 1; }
.crm-score-circle small { font-size: 0.8rem; text-transform: uppercase; color: #7f8c8d; margin-top: 5px; }
.crm-level-info h4 { margin: 0; font-size: 0.9rem; color: #95a5a6; text-transform: uppercase; }
.crm-level-info h2 { margin: 5px 0 10px 0; font-size: 2rem; color: #e67e22; font-weight: 800; }
.crm-level-info p { margin: 0; color: #555; line-height: 1.5; font-size: 1rem; }

/* Box 2: Sections */
.crm-sec-item { margin-bottom: 15px; }
.crm-sec-meta { display: flex; justify-content: space-between; margin-bottom: 5px; font-weight: 600; color: #34495e; font-size: 0.95rem; }
.crm-sec-bar-bg { background: #ecf0f1; height: 10px; border-radius: 5px; overflow: hidden; }
.crm-sec-bar { height: 100%; border-radius: 5px; transition: width 1s ease; }
.crm-sec-bar.good { background: #2ecc71; } /* Green */
.crm-sec-bar.avg { background: #f1c40f; }  /* Yellow */
.crm-sec-bar.bad { background: #e74c3c; }  /* Red */

/* Column 2: Recommendations */
.crm-recs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.crm-rec-box { display: block; background: #fff; border-radius: 10px; overflow: hidden; text-decoration: none; box-shadow: 0 4px 15px rgba(0,0,0,0.05); transition: all 0.3s ease; border: 1px solid #eee; position: relative; top: 0; }
.crm-rec-box:hover { top: -5px; box-shadow: 0 15px 30px rgba(0,0,0,0.1); border-color: #3498db; }

.crm-rec-img { height: 140px; background-size: cover; background-position: center; background-color: #ecf0f1; position: relative; }
.crm-rec-img.crm-no-img { display: flex; align-items: center; justify-content: center; color: #bdc3c7; }
.crm-rec-img.crm-no-img span { font-size: 40px; }

.crm-rec-content { padding: 15px; }
.crm-rec-title { font-weight: 700; color: #2c3e50; font-size: 1rem; margin-bottom: 10px; line-height: 1.4; height: 2.8em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.crm-rec-cta { display: inline-block; font-size: 0.85rem; font-weight: 600; color: #3498db; text-transform: uppercase; }
.crm-rec-box:hover .crm-rec-cta { color: #2980b9; text-decoration: underline; }