/* v8.5.6 MASTER OPTİMİZASYON PAKETİ - NİHAİ CSS */
:root {
    --ana-kirmizi: #e74c3c;
    --grad-bas: #b20a11;
    --grad-bit: #1a1a4b;
    --arka-plan: #f4f7f9;
    --beyaz: #ffffff;
    --siyah: #1a1a1a;
    --golge: 0 10px 30px rgba(0,0,0,0.08);
}

/* Temel Sıfırlama */
@page { size: A4; margin: 0; }
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Montserrat', sans-serif; -webkit-tap-highlight-color: transparent; }

body { 
    background-color: var(--arka-plan); 
    color: var(--siyah); 
    display: flex; 
    min-height: 100vh;
    user-select: none;
    overflow-x: hidden; /* Yatay kaymayı engeller */
}

/* SIDEBAR TASARIMI */
#sidebar { 
    width: 320px; 
    height: 100vh; 
    background: var(--beyaz); 
    padding: 25px; 
    position: fixed; 
    border-right: 2px solid #eee; 
    z-index: 1000; 
    overflow-y: auto;
    box-shadow: var(--golge);
    display: flex;
    flex-direction: column;
}

.mini-title { font-size: 0.65rem; color: var(--ana-kirmizi); font-weight: 700; text-transform: uppercase; letter-spacing: 4px; margin-bottom: -5px; display: block; }
.brand { font-size: 1.6rem; font-weight: 700; margin-bottom: 20px; }
.brand span { color: var(--ana-kirmizi); }

/* YARDIM KUTUSU */
.help-container { margin-bottom: 20px; }
.btn-help {
    width: 100%; padding: 10px; background: #f8f9fa; border: 2px dashed #d1d8e0;
    border-radius: 10px; color: var(--siyah); font-size: 11px; font-weight: 700;
    cursor: pointer; transition: all 0.3s ease; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.help-box {
    display: none; background: var(--beyaz); border: 1px solid #eee; border-radius: 12px;
    padding: 15px; margin-top: 10px; box-shadow: var(--golge); animation: slideDown 0.4s ease forwards;
}
.help-item { margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid #f0f0f0; }
.help-item strong { display: block; font-size: 10px; color: var(--ana-kirmizi); text-transform: uppercase; margin-bottom: 3px; }
.help-item span { font-size: 11px; color: #555; line-height: 1.4; }
.help-footer { font-size: 9px; text-align: center; color: #bbb; margin-top: 5px; font-weight: 600; }

@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* BUTONLAR VE GİRİŞLER */
.input-group label { display: block; font-size: 11px; font-weight: 700; color: #666; margin-bottom: 6px; }
.input-group input, .input-group select { width: 100%; padding: 12px; background: #f8f9fa; border: 2px solid #eaedf0; border-radius: 10px; font-size: 14px; margin-bottom: 15px; }
.btn-generate { 
    width: 100%; padding: 15px; background: linear-gradient(135deg, var(--grad-bas), var(--ana-kirmizi)); 
    color: white; border: none; border-radius: 12px; cursor: pointer; font-weight: bold; font-size: 14px;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3); margin-bottom: 12px;
}
.btn-print { width: 100%; padding: 12px; background: var(--siyah); color: white; border: none; border-radius: 10px; cursor: pointer; font-weight: bold; }

/* FOOTER */
.sidebar-footer { margin-top: auto; padding-top: 20px; border-top: 1px solid #f0f0f0; text-align: center; }
.sidebar-footer a { color: var(--ana-kirmizi); text-decoration: none; font-weight: 700; font-size: 12px; display: block; margin-bottom: 4px; }
.sidebar-footer p { font-size: 10px; color: #999; font-weight: 500; letter-spacing: 0.3px; }

/* ÖNİZLEME ALANI (Masaüstü) */
#paper-preview { 
    margin-left: 320px; 
    width: calc(100% - 320px); 
    display: flex; 
    justify-content: center; 
    padding: 20px; 
    background: var(--arka-plan);
}

.a4-page { 
    width: 210mm; 
    height: 297mm; 
    background: white; 
    padding: 10mm 12mm; 
    display: flex; 
    flex-direction: column; 
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

/* KAĞIT İÇERİĞİ */
.sheet-header { display: flex; border: 2px solid #000; height: 25mm; margin-bottom: 4mm; }
.header-box { padding: 4mm; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.info { font-size: 11px; }
.school { border-left: 2px solid #000; text-align: center; }
#displaySchool { font-size: 14px; font-weight: 800; text-transform: uppercase; margin-bottom: 8px; }
.header-date { font-size: 11px; border-top: 1px dashed #999; padding-top: 4px; }
h1 { text-align: center; font-size: 18px; color: var(--ana-kirmizi); margin-bottom: 3mm; text-transform: uppercase; }
.instruction { font-size: 11px; border-left: 4px solid var(--ana-kirmizi); padding-left: 10px; margin-bottom: 5mm; }
.questions-grid { display: grid; gap: 8px; grid-template-columns: 1fr; grid-template-rows: repeat(4, 55mm); }
.question-item { border: 1px solid #ddd; padding: 8px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; }
.instrument-group-img { max-width: 90%; max-height: 28mm; object-fit: contain; }
.answer-section { width: 100%; margin-top: 5px; }
.answer-row { display: flex; align-items: flex-end; margin-bottom: 4px; }
.answer-label { font-size: 10px; font-weight: bold; width: 95px; }
.answer-line-long { flex-grow: 1; border-bottom: 1px solid #000; height: 14px; }

/* MOBİL GÖRÜNÜM NİHAİ DÜZELTME */
@media (max-width: 1024px) {
    body { flex-direction: column; }
    
    #sidebar { 
        width: 100%; 
        height: auto; 
        position: relative; 
        border-right: none; 
        border-bottom: 2px solid #eee;
        padding: 15px;
    }

    #paper-preview { 
        margin-left: 0; 
        width: 100%; 
        padding: 0; 
        display: flex; /* Flex ile tam ortalamayı garanti ediyoruz */
        justify-content: center; 
        align-items: flex-start;
        min-height: 500px;
        overflow: hidden; /* Kağıdın yana taşmasını gizle */
    }

    .a4-page { 
        transform: scale(0.42); /* Biraz daha küçülterek güvenli alana çektik */
        transform-origin: top center; /* Tam tepeden ve ortadan ölçekle */
        margin: 20px 0 -160mm 0; /* Üstte 20px boşluk, alttaki devasa boşluğu sil */
        flex-shrink: 0; /* Ölçeklenirken kutusunun büzülmesini engelle */
    }
}

/* YAZDIRMA */
@media print {
    #sidebar { display: none !important; }
    #paper-preview { margin: 0; padding: 0; width: 100%; }
    .a4-page { margin: 0; border: none; box-shadow: none; transform: scale(1); }
}