/* =========================================================
   Ortak AI Modal Stilleri
   Bu dosya sinavAi.css, ogrenciAi.css ve ogretmenAi.css arasında paylaşılan
   temel modal bileşenlerini barındırır.
   ========================================================= */

/* Modal açıkken kaydırmayı engelle */
body.modal-open,
html.modal-open {
    overflow: hidden;
}

/* Modal Arka Planı */
.modal {
    display: none;
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s;
}

/* Modal İçerik Kutusu */
.modal-icerik {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 800px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    box-sizing: border-box;
}

#ai-modal .modal-icerik {
    max-height: 85vh;
    overflow-y: auto;
}

.ai-modal-heading {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-sizing: border-box;
    padding: 14px 32px;
    margin: 0 0 20px 0;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    background: linear-gradient(135deg, #10b981 0%, #0ea5e9 50%, #06b6d4 100%);
    color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(16, 185, 129, 0.25);
    width: fit-content;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

.ai-modal-heading svg {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
}

.ai-modal-heading span {
    display: inline-block;
    font-weight: 700;
    font-size: 1.05rem;
    color: inherit;
    word-spacing: 0.35em;
}

.mobile-break {
    display: none;
}

/* Kapatma Butonu */
.kapat-dugme {
    color: #999;
    position: absolute;
    top: 1px;
    right: 5px;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    z-index: 1051;
    transition: color 0.2s ease;
}

.kapat-dugme:hover,
.kapat-dugme:focus {
    color: #333;
    text-decoration: none;
}

/* Yükleme animasyonu (Spinner) */
.gemini-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #c82323;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

/* =========================================================
   AI MODAL İÇERİK STİLLERİ
   ========================================================= */

/* =========================================================
   AI MODAL BODY - ANA KONTEYNER
   ========================================================= */
#ai-modal-body {
    font-size: 0.95rem;
    color: #1f2937;
    font-weight: 500;
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

/* =========================================================
   AI BÖLÜMLERI - BASİT, DÜZGÜN CONTAINER
   ========================================================= */
#ai-modal-body .ai-section {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 16px 20px;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    border: none;
}

#ai-modal-body .ai-section:nth-child(even) {
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.5), #ffffff);
}

#ai-modal-body .ai-section:nth-child(odd) {
    background: #ffffff;
}

/* İç içe wrapper - gerçek şekillendirme burada */
#ai-modal-body .ai-section-wrapper {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 24px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.9), #ffffff);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.10);
    border: 1px solid rgba(148, 163, 184, 0.15);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}

/* Tüm içerik tam genişlik */
#ai-modal-body .ai-section-wrapper > * {
    width: 100%;
    box-sizing: border-box;
}

/* Alt bölüm kartları */
#ai-modal-body .ai-subsection-card {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

#ai-modal-body .ai-subsection-card.highlight {
    background: transparent;
    border-color: transparent;
}

/* =========================================================
   AI BÖLÜM BAŞLIKLARı
   ========================================================= */
/* Force all modal section headings to be centered */
#ai-modal-body h3,
#ai-modal-body h4,
#ai-modal-body .ai-section-title {
    text-align: center !important;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

#ai-modal-body .ai-section h4,
#ai-modal-body .ai-section-title {
    color: #0891b2;
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    position: relative;
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.08);
    box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.12);
    width: fit-content;
}

/* Highly specific overrides to ensure all headings inside subsection-cards and wrappers are centered */
#ai-modal-body .ai-subsection-card h4,
#ai-modal-body .ai-subsection-card .ai-section-title,
#ai-modal-body .ai-section-wrapper h4,
#ai-modal-body .ai-section-wrapper .ai-section-title {
    text-align: center !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin: 0 auto !important;
    width: auto !important;
}

/* Decorative underline (hidden by default on small headings) */
#ai-modal-body .ai-section h4::after,
#ai-modal-body .ai-section-title::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -6px;
    transform: translateX(-50%);
    width: 100%;
    max-width: 90%;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, #10b981, #0ea5e9);
}

/* =========================================================
   AI MODAL METİN STİLLERİ
   ========================================================= */
#ai-modal-body p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #1f2937;
    font-weight: 500;
    text-align: justify;
    text-justify: inter-word;
    margin: 0 0 12px 0;
}

.bilgi-mesaji {
    text-align: center;
    padding: 15px;
    background-color: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-top: 20px;
    font-style: italic;
}

/* =========================================================
   NORMAL BÖLÜMLER - GRADIENT BORDER WRAPPER
   ========================================================= */

/* Normal bölümler (Genel Değerlendirme, Güçlü Yönlerin, vb.) */
.ai-section-wrapper.gradient-border {
    border: 2px solid !important;
    border-image: linear-gradient(135deg, #10b981 0%, #0ea5e9 50%, #06b6d4 100%) 1 !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 24px;
    border-radius: 12px;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    word-wrap: break-word;
}

/* Normal bölüm başlıkları - kutu stili */
.ai-section-wrapper.gradient-border h4 {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    padding: 6px 16px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 auto 16px auto;
    background: linear-gradient(135deg, #e0f2fe 0%, #d1fae5 100%);
    color: #0e7490;
    border: 2px solid #06b6d4;
    animation: none !important;
    box-sizing: border-box;
    width: fit-content;
    max-width: 100%;
}

/* Altındaki çizgiyi kaldır */
.ai-section-wrapper.gradient-border h4::after {
    display: none !important;
}

/* =========================================================
   DESKTOP STYLES (Masaüstü Stilleri)
   ========================================================= */

/* Masaüstü - Ders Başarı Header tek satırda */
.lesson-success-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
}

/* Mobilde gösterilecek geçen yıl bilgilerini masaüstünde gizle */
.lesson-success-right {
    display: none;
}

/* =========================================================
   RESPONSİVE TASARIM (768px ve altı)
   ========================================================= */

@media screen and (max-width: 768px) {
    /* Sınav paneli trend ve tablo ayarları */
    .exam-trend-heading {
        align-items: center;
    }

    .exam-trend-chip-group {
        width: 100%;
        justify-content: center;
    }

    .exam-trend-summary {
        font-size: 0.9rem;
    }

    .exam-trend-chip {
        font-size: 0.85rem;
        padding: 6px 12px;
    }

    .subject-performance-table {
        font-size: 0.9rem;
    }

    .subject-performance-table th,
    .subject-performance-table td {
        padding: 6px;
    }

    /* Ortak modal düzenlemeleri */
    .modal-icerik {
        width: 92%;
        margin: 10% auto;
        padding: 15px;
        box-sizing: border-box;
    }

    #ai-modal .modal-icerik {
        max-height: 80vh;
        overflow-y: auto;
    }

    h1, h2, h3, h4 {
        font-size: 1.15rem;
    }

    .ai-modal-heading {
        font-size: 1.2rem;
    }

    #ai-modal-body .ai-section h4,
    .ai-section-title {
        font-size: 1.3rem;
    }

    #ai-modal-body .ai-section {
        padding: 12px;
    }

    #ai-modal-body .ai-section-wrapper {
        padding: 16px 14px;
        border-radius: 12px;
    }

    .kategori-uyari {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        padding: 1.25rem;
        text-align: center;
    }

    .kategori-uyari .uyari-ikon {
        font-size: 2rem;
    }

    .kategori-uyari .uyari-icerik h4 {
        text-align: center !important;
        justify-content: center;
    }

    .kategori-uyari .uyari-icerik p {
        text-align: center;
    }

    #ai-modal-body .rozetler-container {
        grid-template-columns: 1fr;
    }

    /* Trend Bölümü Mobil */
    .trend-container {
        gap: 12px;
    }

    .trend-graph-section {
        flex-direction: column;
        gap: 12px;
    }

    .trend-sparkline-section {
        width: 100%;
        min-width: 100%;
    }

    .trend-text-section {
        width: 100%;
    }

    .trend-history-items {
        gap: 10px;
        margin-top: 12px;
    }

    .trend-year-card {
        min-width: 65px;
        padding: 10px 12px;
    }

    .trend-year-label {
        font-size: 0.75rem;
    }

    .trend-year-value {
        font-size: 1rem;
    }

    .teacher-ai-section {
        padding: 12px;
        margin-bottom: 16px;
    }

    .distribution-visuals {
        flex-direction: column;
    }

    .distribution-curve-header {
        flex-wrap: nowrap;
        justify-content: center;
        gap: 6px;
        width: 100%;
        box-sizing: border-box;
    }

    .distribution-curve-title,
    .distribution-curve-subtitle {
        flex: 0 1 auto;
        font-size: 0.72rem;
        padding: 3px 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        min-width: fit-content;
    }

    .distribution-curve-title {
        order: 1;
    }

    .distribution-curve-subtitle {
        order: 2;
    }

    .distribution-curve-legend {
        order: 999;
        flex-basis: 100%;
        justify-content: center;
        gap: 12px;
        margin-top: 8px;
    }

    .trend-container {
        flex-direction: column;
        gap: 12px;
    }

    .student-groups-grid {
        grid-template-columns: 1fr;
    }

    .exam-trend-table {
        font-size: 0.75rem;
    }

    .exam-trend-cell {
        padding: 8px;
    }

    /* Ders Bazlı Performans - Mobil Düzen (ogretmen paneli) */
    body .lesson-focus-row {
        flex-direction: column;
        align-items: stretch;
        padding: 16px 12px;
        gap: 8px;
    }

    body .lesson-name {
        flex: 1 1 auto;
        text-align: center;
        font-size: 1rem;
        margin-bottom: 6px;
    }

    body .lesson-success-container {
        flex: 1 1 auto;
        margin: 0;
    }

    body .lesson-success-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 4px;
    }

    /* Sağ taraf: Geçen Yıl Bilgisi (mobilde göster) */
    body .lesson-success-right {
        display: flex !important;
        align-items: center;
        gap: 4px;
        font-size: 14px;
        font-weight: 500;
        flex-shrink: 0;
        white-space: nowrap;
    }

    body .lesson-previous-year {
        display: block !important;
    }

    body .lesson-change-container {
        display: none;
    }
}

/* =========================================================
   MOBİL TASARIM (480px ve altı)
   ========================================================= */

@media screen and (max-width: 480px) {
    /* Sınav paneli trend/tablo ayarları */
    .exam-trend-table {
        min-width: 280px;
    }

    .exam-trend-cell {
        padding: 8px 10px;
        font-size: 0.9rem;
    }

    .exam-trend-table-head th {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .exam-trend-chip {
        font-size: 0.8rem;
        padding: 5px 10px;
    }

    .exam-trend-chip-group {
        gap: 6px;
    }

    /* Mobil: Distribution Curve başlıkları yanyana - 480px altında */
    .distribution-curve-header {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .distribution-curve-title {
        flex: 0 0 auto !important;
        order: 1 !important;
        white-space: nowrap !important;
        font-size: 0.7rem !important;
        padding: 2px 4px !important;
    }

    .distribution-curve-subtitle {
        flex: 0 0 auto !important;
        order: 1 !important;
        white-space: nowrap !important;
        font-size: 0.7rem !important;
        padding: 2px 4px !important;
    }

    .distribution-curve-legend {
        order: 2 !important;
        flex-basis: 100% !important;
        justify-content: center !important;
        gap: 8px !important;
        margin-top: 4px !important;
        display: flex !important;
    }

    .subject-performance-table th,
    .subject-performance-table td {
        padding: 5px;
        font-size: 0.85rem;
    }

    /* Ortak modal düzenlemeleri */
    .modal-icerik {
        width: 95%;
        margin: 15% auto;
        padding: 8px;
        max-width: 100%;
        box-sizing: border-box;
    }

    #ai-modal-body {
        width: 100%;
        box-sizing: border-box;
        font-size: 0.9rem;
        color: #1f2937;
        font-weight: 500;
        line-height: 1.5;
        margin: 0;
        padding: 0;
    }

    #ai-modal-body .ai-section {
        padding: 8px 12px;
    }

    .ai-modal-heading {
        font-size: 0.95rem;
        padding: 10px 16px;
        gap: 8px;
        margin: 0 0 15px 0;
        flex-wrap: wrap;
        width: auto;
        max-width: 100%;
    }

    .ai-modal-heading svg {
        width: 18px;
        height: 18px;
    }

    .ai-modal-heading span {
        font-size: 0.9rem;
        white-space: normal;
        display: block;
        max-width: 220px;
        margin: 0 auto;
        text-transform: uppercase;
    }

    .mobile-break {
        display: block;
    }

    #ai-modal-body .ai-section-wrapper {
        width: 100%;
        max-width: 100%;
        padding: 12px;
        margin: 0;
        box-sizing: border-box;
        border-radius: 10px;
        gap: 10px;
    }

    #ai-modal-body .ai-section-wrapper.gradient-border {
        padding: 12px;
        border-radius: 10px;
    }

    #ai-modal-body .ai-subsection-card {
        padding: 0;
        margin: 0;
        background: transparent;
        border: none;
        box-shadow: none;
    }

    #ai-modal-body .ai-section-wrapper > * {
        width: 100%;
        box-sizing: border-box;
        max-width: 100%;
    }

    #ai-modal-body h4 {
        font-size: 1rem;
    }

    #ai-modal-body h3 {
        font-size: 1.1rem;
    }

    #ai-modal-body .rozet-baslik {
        font-size: 0.9rem;
    }

    #ai-modal-body .rozet-aciklama {
        font-size: 0.8rem;
    }

    #ai-modal-body .rozet-section p {
        font-size: 0.85rem;
    }

    #ai-modal-body strong {
        font-weight: 600;
        font-size: 0.9rem;
    }

    .bilgi-mesaji {
        font-size: 0.85rem;
        padding: 12px;
    }

    #ai-modal-body .rozetler-container {
        grid-template-columns: 1fr;
        gap: 10px;
        row-gap: 5px;
        margin: 0.5rem 0;
    }

    #ai-modal-body .rozet-item {
        padding: 8px;
        margin-bottom: 8px;
    }

    /* Öğrenci paneli özel alanları */
    .kategori-uyari {
        padding: 12px;
        gap: 0.5rem;
        margin-bottom: 12px;
    }

    .kategori-uyari .uyari-ikon {
        font-size: 1.8rem;
    }

    .kategori-uyari .uyari-icerik {
        width: 100%;
    }

    .kategori-uyari .uyari-icerik h4 {
        font-size: 1rem;
        margin: 0 0 0.5rem 0;
        padding: 6px 12px;
    }

    .kategori-uyari .uyari-icerik p {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    #hedefAnalizi {
        gap: 12px;
        margin-bottom: 15px;
        width: 100%;
    }

    .hedef-kutu {
        padding: 15px;
        margin: 0;
    }

    .hedef-kutu-baslik {
        font-size: 1rem;
    }

    .okul-adi {
        font-size: 1rem;
        word-break: break-word;
    }

    /* Öğretmen paneli özel alanları */
    .lesson-name {
        flex: 0 0 auto;
        font-size: 0.95rem;
    }

    .lesson-progress-bar {
        height: 6px;
    }

    .lesson-success-header {
        gap: 6px;
    }

    /* Trend Bölümü Çok Küçük Mobil (480px) */
    .trend-container {
        gap: 8px;
    }

    .trend-history-items {
        gap: 8px;
        margin-top: 10px;
    }

    .trend-year-card {
        min-width: 60px;
        padding: 8px 10px;
        gap: 3px;
    }

    .trend-year-label {
        font-size: 0.7rem;
    }

    .trend-year-value {
        font-size: 0.95rem;
    }

    .trend-change-sentence {
        font-size: 0.85rem;
    }

    .lesson-success-left {
        gap: 6px;
    }

    .lesson-success-right {
        display: flex !important;
        gap: 3px;
        font-size: 14px;
    }
    
    .lesson-previous-year {
        display: block !important;
    }

    .teacher-ai-section {
        padding: 10px;
        margin-bottom: 12px;
    }

    .teacher-ai-section h4 {
        font-size: 1rem;
    }

    .distribution-bar-label {
        min-width: 80px;
        font-size: 0.75rem;
    }

    .student-groups-grid {
        gap: 12px;
    }

    .student-group-card {
        padding: 12px 14px;
    }

    .exam-trend-chip {
        font-size: 0.65rem;
    }

    .exam-trend-table {
        font-size: 0.7rem;
    }

    .exam-trend-cell {
        padding: 6px;
    }
}

/* =========================================================
   ANİMASYONLAR
   ========================================================= */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
