:root {
    --question-button-color1: #fa0000;
    --question-button-color1-chosen: #c80000;
    --question-button-color2: #009600;
    --question-button-color2-chosen: #006400;
    --question-button-font-color: #f5deb3;
    --question-button-font-color-chosen: #deb887;
    --question-page-background-color: #13546d;
    --question-page-option-color: #ffa600;
    --question-page-font-color: #ffffff;
}

@font-face {
    font-family: "Lyon Arabic Text";
    src: url(../font.otf);
}

* {
    user-select: none;
    font-family: "Lyon Arabic Text", sans-serif;
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 20px;
    background: #f0f2f5;
    color: #333;
}

.section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
}

#questionsContainer {
    counter-reset: q-counter;
}

.question {
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 15px;
    background: #fff;
    margin-bottom: 15px;
    position: relative;
    transition: all 0.3s;
}

.question::before {
    counter-increment: q-counter;
    content: counter(q-counter);
    position: absolute;
    top: -10px;
    right: -10px;
    background: #007bff;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.qText,
#nashatInput {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

#nashatInput {
    display: block;
    /* Default state matches "new" */
}

.choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.choices label {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #eee;
}

.choices input[type="text"] {
    flex: 1;
    border: 1px solid #ccc;
    padding: 5px;
    border-radius: 3px;
}

/* Error state */
.required-error {
    border: 2px solid #ff0000 !important;
    background-color: #fff0f0 !important;
}

.img-slot {
    display: flex;
    flex-direction: column;
    gap: 5px;
    border: 1px dashed #bbb;
    padding: 10px;
    border-radius: 8px;
    align-items: center;
}

.img-preview {
    width: 80px;
    height: 60px;
    object-fit: contain;
    background: #eee;
    border: 1px solid #ddd;
}

button {
    cursor: pointer;
    padding: 10px 18px;
    border-radius: 6px;
    border: none;
    font-weight: bold;
    transition: 0.2s;
}

.btn-add {
    background: #28a745;
    color: white;
}

.btn-api {
    background: #6f42c1;
    color: white;
}

.btn-export {
    background: #007bff;
    color: white;
}

.btn-upload {
    background: #28a745;
    color: white;
}

.btn-del {
    background: #dc3545;
    color: white;
    padding: 5px 10px;
}

.btn-clear {
    background: #e63946;
    color: white;
    margin-right: 10px;
}

.btn-move {
    background: #e9ecef;
    color: #333;
    padding: 5px 10px;
}

.list-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
}

.search-input {
    flex: 1;
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid #ccc;
}

.previewBox {
    background: var(--question-page-background-color);
    color: var(--question-page-font-color);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.choicePreview {
    background: var(--question-page-option-color);
    margin: 8px auto;
    width: 70%;
    padding: 10px;
    border-radius: 5px;
}

/* New Grid Preview Styles */
.gridPreviewBox {
    background: #f8f9fa;
    border: 2px solid #ddd;
    padding: 20px;
    border-radius: 10px;
    margin-top: 10px;
    min-height: 100px;
}

.questionsGridPreview {
    display: flex;
    flex-wrap: wrap;
    /* This handles the centering of the last row automatically */
    justify-content: center;
    gap: 10px;
    /* Limit width to roughly 7 items (7 * 60px + gaps) to force wrapping */
    max-width: 500px;
    margin: 0 auto;
    direction: ltr;
}

/* Remove the transform logic entirely */
.questionsGridPreview>div {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    /* Prevents boxes from squishing */
}

.qNumberPreview {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 8px;
    color: var(--question-button-font-color);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}

/* Simulate the color alternating logic used in many quiz apps */
.qNumberPreview:nth-child(odd) {
    background-color: var(--question-button-color1);
}

.qNumberPreview:nth-child(even) {
    background-color: var(--question-button-color2);
}