* {
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    margin: 0;
    padding: 0;
    background-color: #f1f5f9;
    color: #1e293b;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sol Panel Stilleri */
.sidebar {
    width: 400px;
    background-color: white;
    border-right: 1px solid #e2e8f0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    z-index: 10;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 24px;
    color: #0f172a;
}

.form-group {
    margin-bottom: 20px;
}

.form-group > label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #334155;
}

input[type="text"], input[type="number"], select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    border-color: #3b82f6;
}

.row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.type-selector {
    display: flex;
    gap: 12px;
}

.type-btn {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.type-btn strong {
    display: block;
    font-size: 15px;
    margin-bottom: 4px;
    color: #475569;
}

.type-btn span {
    display: block;
    font-size: 12px;
    color: #94a3b8;
}

.type-btn.active {
    border-color: #3b82f6;
    background-color: #eff6ff;
}

.type-btn.active strong, .type-btn.active span {
    color: #2563eb;
}

.preset-buttons {
    display: flex;
    gap: 8px;
}

.preset-btn {
    flex: 1;
    padding: 8px 0;
    border: 1px solid #cbd5e1;
    background-color: white;
    color: #475569;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    background-color: #f1f5f9;
}

.preset-btn.active {
    background-color: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.section-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
}

.section-row input[type="text"] {
    flex: 1;
}

.section-row input[type="number"] {
    width: 70px;
    text-align: center;
}

.btn-delete {
    background: none;
    border: 1px solid #cbd5e1;
    color: #ef4444;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete:hover {
    background-color: #fef2f2;
    border-color: #ef4444;
}

.sections-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.section-limit-message {
    display: none;
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid #fecaca;
    border-radius: 6px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 12px;
    font-weight: 700;
}

.section-limit-message.show {
    display: block;
}

.btn {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    border: none;
}

.btn-light {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.btn-light:hover {
    background-color: #e2e8f0;
}

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

.btn-primary:hover {
    background-color: #2563eb;
}

.total-text {
    font-size: 14px;
    font-weight: 600;
    color: #10b981;
}

.actions-bottom {
    margin-top: auto;
    padding-top: 20px;
}

/* Sağ Panel - Ön İzleme */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #94a3b8;
    position: relative;
}

.preview-toolbar {
    height: 50px;
    background-color: #1e293b;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 5;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.zoom-controls button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
}

.paper-container {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    padding: 40px;
}

.paper {
    background-color: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    position: relative;
    transform-origin: top center;
    transition: transform 0.2s;
    --paper-pad: 10mm;
    --aruco-size: 8mm;
    --aruco-half: 4mm;
    padding: 10mm;
    box-sizing: border-box;
}

.aruco-marker {
    position: absolute;
    width: var(--aruco-size);
    height: var(--aruco-size);
    display: block;
    background: #fff;
    z-index: 2;
}

.aruco-marker svg {
    display: block;
    width: 100%;
    height: 100%;
}

.marker-tl {
    top: calc(var(--paper-pad) - var(--aruco-half));
    left: calc(var(--paper-pad) - var(--aruco-half));
}
.marker-tr {
    top: calc(var(--paper-pad) - var(--aruco-half));
    right: calc(var(--paper-pad) - var(--aruco-half));
}
.marker-br {
    bottom: calc(var(--paper-pad) - var(--aruco-half));
    right: calc(var(--paper-pad) - var(--aruco-half));
}
.marker-bl {
    bottom: calc(var(--paper-pad) - var(--aruco-half));
    left: calc(var(--paper-pad) - var(--aruco-half));
}

.paper.a4 {
    width: 210mm;
    min-height: 297mm;
}

.paper.a5 {
    width: 148mm;
    min-height: 210mm;
}

.paper.a6 {
    width: 105mm;
    height: 148mm;         /* min-height yerine sabit height — taşmayı önler */
    max-height: 148mm;
    overflow: hidden;
    padding: 6mm;          /* CSS cascade sonraki blok 4mm'ye düşürecek */
}

/* Optik Form İçi Stiller */
.form-content {
    border: 0.35mm solid black;
    height: 100%;
    padding: 5mm;
    display: flex;
    flex-direction: column;
}

.omr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1mm;
    border-bottom: 1px solid black;
    padding-bottom: 1mm;
}

.omr-header .header-left,
.omr-header .header-right {
    flex: 1;
    font-size: 10px;
    font-weight: bold;
}

.omr-header .header-left {
    text-align: left;
}

.omr-header .header-right {
    text-align: right;
}

.omr-header .header-center {
    flex: 2;
    text-align: center;
    font-size: 13px;
    font-weight: bold;
}

.student-info-section {
    display: flex;
    gap: 3mm;
    margin-bottom: 2mm;
}

.info-box {
    flex: 1;
    border: 1px solid black;
    padding: 3mm;
}

.info-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-size: 9px;
    margin-bottom: 2mm;
    width: 100%;
}

.info-row span {
    margin-bottom: 1mm;
}

.write-line {
    width: 100%;
    border-bottom: 1px dotted #666;
    height: 3mm;
}

.coding-area {
    border: 1px solid black;
    padding: 1.5mm;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.coding-title {
    font-size: 9px;
    font-weight: bold;
    margin-bottom: 1.5mm;
}

.coding-grid {
    display: flex;
    gap: 0.8mm;
}

.coding-col {
    display: flex;
    flex-direction: column;
    gap: 0.8mm;
}

.write-box {
    width: 3.5mm;
    height: 3.8mm;
    border: 1px solid black;
    margin-bottom: 0.8mm;
}

.questions-area {
    flex: 1;
    min-height: 0;          /* flex shrink bug düzeltme: içerik sıkışabilsin */
    overflow: hidden;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2mm;
}


.paper.a5 .questions-area {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5mm;
}

.paper.a6 .questions-area {
    grid-template-columns: repeat(2, 1fr);
    gap: 2mm;
}

/* A5: 25 soruluk sütunları A5 çerçevesinde tutar. */
.paper.a5 .form-content {
    padding: 4mm;
    overflow: hidden;
}

.paper.a5 .omr-header {
    margin-bottom: 0.5mm;
    padding-bottom: 0.5mm;
}

.paper.a5 .omr-header .header-left,
.paper.a5 .omr-header .header-right {
    font-size: 8px;
}

.paper.a5 .omr-header .header-center {
    font-size: 11px;
}

.paper.a5 .student-info-section {
    gap: 2mm;
    margin-bottom: 1mm;
    max-height: 48mm;
    overflow: hidden;
    flex-shrink: 0;
}

.paper.a5 .info-box {
    padding: 2mm;
}

.paper.a5 .info-row {
    font-size: 8px;
    margin-bottom: 0.8mm;
}

.paper.a5 .write-line {
    height: 2.4mm;
}

.paper.a5 .coding-area {
    padding: 1mm;
}

.paper.a5 .coding-title {
    font-size: 8px;
    margin-bottom: 0.7mm;
}

.paper.a5 .coding-col {
    gap: 0.35mm;
}

.paper.a5 .write-box {
    width: 3mm;
    height: 2.5mm;
    margin-bottom: 0.4mm;
}

.paper.a5 .student-number-bubble {
    width: 2.6mm;
    height: 2.6mm;
    font-size: 5.5px;
}

.paper.a5 .section-header {
    font-size: 8px;
    padding: 0.4mm 0;
    margin-bottom: 0.7mm;
}

.paper.a5 .q-row {
    margin-bottom: 0.35mm;
    font-size: 8px;
    line-height: 1;
}

.paper.a5 .q-num {
    width: 4.5mm;
    font-size: 8px;
    margin-right: 0.6mm;
}

.paper.a5 .bubble {
    width: 3.3mm;
    height: 3.3mm;
    font-size: 6.5px;
    margin-right: 0.35mm;
}

/* ── A6 Sıkıştırma: 20 soruyu çerçeve içinde tut ──────── */
.paper.a6 {
    padding: 4mm;          /* 6mm → 4mm: her yanda 2mm kazanç */
    --paper-pad: 4mm;
}

.paper.a6 .form-content {
    padding: 3mm;
    overflow: hidden;       /* taşan içerik çerçeve dışına çıkmasın */
}

.paper.a6 .omr-header {
    margin-bottom: 0.2mm;
    padding-bottom: 0.2mm;
}

.paper.a6 .omr-header .header-left,
.paper.a6 .omr-header .header-right {
    font-size: 8px;
}

.paper.a6 .omr-header .header-center {
    font-size: 9px;        /* 11px → 9px */
    font-weight: 800;
}

.paper.a6 .student-info-section {
    margin-bottom: 0.5mm;
    gap: 1mm;
    max-height: 34mm;          /* öğrenci no alanının çerçevi zorla sınırla */
    overflow: hidden;
    flex-shrink: 0;
}

.paper.a6 .info-box {
    padding: 1.5mm;
}

.paper.a6 .info-row {
    margin-bottom: 0.4mm;  /* 1mm → 0.4mm */
    height: auto;
    font-size: 8px;
}

.paper.a6 .write-line {
    height: 2mm;           /* 2.5mm → 2mm */
}

.paper.a6 .coding-area {
    padding: 0.8mm;
}

.paper.a6 .coding-title {
    font-size: 7px;
    font-weight: bold;
    margin-bottom: 0.5mm;
}

.paper.a6 .bubble {
    width: 3.4mm;
    height: 3.4mm;
    font-size: 7px;
    margin-right: 0.5mm;
}

.paper.a6 .student-number-bubble {
    width: 2.2mm;
    height: 2.2mm;
    font-size: 5px;
}

.paper.a6 .coding-col {
    gap: 0.25mm;
}

.paper.a6 .write-box {
    width: 2.8mm;
    height: 2mm;
    margin-bottom: 0.3mm;
}
/* ── /A6 Sıkıştırma ──────────────────────────────────── */

.paper.a6 .section-header {
    font-size: 8px;
    padding: 0.3mm 0;
    margin-bottom: 0.5mm;
}

.paper.a6 .q-row {
    margin-bottom: 0.4mm;
    font-size: 8px;
    line-height: 1;
}

.paper.a6 .q-num {
    width: 4mm;
    font-size: 8px;
    margin-right: 0.5mm;
}

.paper.a6 .bubble {
    width: 2.75mm;
    height: 2.75mm;
    font-size: 6.5px;
    margin-right: 0.25mm;
}

.question-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.section-header {
    font-size: 10px;
    font-weight: bold;
    text-align: center;
    background-color: #eee;
    border: 1px solid black;
    padding: 1mm 0;
    margin-bottom: 1.5mm;
}

.q-row {
    display: flex;
    align-items: center;
    margin-bottom: 0.8mm;
    font-size: 9px;
    flex-shrink: 0;
}

.q-row-spacer {
    color: #fff;
    pointer-events: none;
}

.q-row-spacer .q-num,
.q-row-spacer .bubble {
    border-color: #fff;
    background-color: #fff;
    color: #fff;
}

.q-num {
    width: 5mm;
    text-align: right;
    margin-right: 1mm;
    font-weight: bold;
    flex: 0 0 auto;
}

.bubble {
    width: 3.8mm;
    height: 3.8mm;
    border: 1px solid black;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 7.5px;
    margin-right: 0.8mm;
    background-color: white;
    flex: 0 0 auto;
}

.student-number-bubble {
    width: 3.2mm;
    height: 3.2mm;
    border: 1px solid black;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 6px;
}

/* form_create eski form yapisi: A5/A6 kolon ve balon olculeri */
.paper.a5 {
    min-height: 210mm;
    height: auto;
    max-height: none;
    overflow: visible;
}

.paper.a6 {
    min-height: 148mm;
    height: auto;
    max-height: none;
    overflow: visible;
    --paper-pad: 6mm;
    padding: 6mm;
}

.questions-area {
    min-height: auto;
    overflow: visible;
    gap: 2mm;
}

.paper.a5 .questions-area {
    grid-template-columns: repeat(4, 1fr);
    gap: 2mm;
}

.paper.a6 .questions-area {
    grid-template-columns: repeat(2, 1fr);
    gap: 2mm;
}

.paper.a5 .form-content,
.paper.a6 .form-content {
    padding: 5mm;
    overflow: visible;
}

.paper.a5 .form-content,
.paper.a6 .form-content,
.paper.a4 .form-content {
    border: 0.35mm solid black;
}

.paper.a6 .form-content {
    padding-top: 3.5mm;
}

.paper.a5 .omr-header,
.paper.a6 .omr-header {
    margin-bottom: 0.5mm;
    padding-bottom: 0.5mm;
}

.paper.a6 .omr-header {
    margin-bottom: 0.2mm;
    padding-bottom: 0.2mm;
}

.paper.a5 .omr-header .header-left,
.paper.a5 .omr-header .header-right,
.paper.a6 .omr-header .header-left,
.paper.a6 .omr-header .header-right {
    font-size: 10px;
}

.paper.a5 .omr-header .header-center,
.paper.a6 .omr-header .header-center {
    font-size: 11px;
    font-weight: bold;
}

.paper.a5 .student-info-section,
.paper.a6 .student-info-section {
    gap: 3mm;
    margin-bottom: 2mm;
    max-height: none;
    overflow: visible;
}

.paper.a5 .info-box,
.paper.a6 .info-box {
    padding: 3mm;
}

.paper.a5 .info-row,
.paper.a6 .info-row {
    font-size: 9px;
    margin-bottom: 1mm;
    height: auto;
}

.paper.a5 .write-line,
.paper.a6 .write-line {
    height: 2.5mm;
}

.paper.a5 .coding-area,
.paper.a6 .coding-area {
    padding: 1.5mm;
}

.paper.a5 .coding-title,
.paper.a6 .coding-title {
    font-size: 9px;
    margin-bottom: 1.5mm;
}

.paper.a5 .coding-col,
.paper.a6 .coding-col {
    gap: 0.8mm;
}

.paper.a5 .write-box,
.paper.a6 .write-box {
    width: 3.5mm;
    height: 3.8mm;
    margin-bottom: 0.8mm;
}

.paper.a5 .student-number-bubble,
.paper.a6 .student-number-bubble {
    width: 3.2mm;
    height: 3.2mm;
    font-size: 6px;
}

.paper.a5 .section-header,
.paper.a6 .section-header {
    font-size: 10px;
    padding: 1mm 0;
    margin-bottom: 1.5mm;
}

.paper.a6 .section-header {
    padding: 0.4mm 0;
    margin-bottom: 0.7mm;
}

.paper.a5 .q-row,
.paper.a6 .q-row,
.q-row {
    margin-bottom: 0.8mm;
    font-size: 9px;
    line-height: normal;
    flex-shrink: 1;
}

.paper.a5 .q-num,
.paper.a6 .q-num,
.q-num {
    width: 5mm;
    font-size: 9px;
    margin-right: 1mm;
    flex: initial;
}

.paper.a5 .bubble,
.paper.a6 .bubble,
.bubble {
    width: 3.8mm;
    height: 3.8mm;
    font-size: 7.5px;
    margin-right: 0.8mm;
    flex: initial;
}
