/* ============================================================
   📊 ÖĞRETMEN RAPOR PANELİ — Premium Tasarım
   Kapsül Koçluk Sistemi v1.0
   ============================================================ */

/* --- SECTION WRAPPER --- */
#teacher-report-section {
    padding: 0;
    min-height: calc(100vh - 60px);
    background: var(--background-color, #f8fafc);
}

/* --- PANEL HEADER --- */
.tr-header {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4c1d95 100%);
    color: white;
    padding: 28px 32px 24px;
    border-radius: 0 0 24px 24px;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(76, 29, 149, 0.35);
}

.tr-header::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 220px;
    height: 220px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
}

.tr-header::after {
    content: '';
    position: absolute;
    bottom: -80px;
    left: 30%;
    width: 300px;
    height: 300px;
    background: rgba(139, 92, 246, 0.12);
    border-radius: 50%;
}

.tr-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    z-index: 1;
    flex-wrap: wrap;
    gap: 16px;
}

.tr-header h2 {
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: white;
}

.tr-header p {
    margin: 0;
    font-size: 13px;
    opacity: 0.75;
    font-weight: 400;
}

.tr-header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* --- BUTTONS --- */
.tr-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tr-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.tr-btn-primary {
    background: #8b5cf6;
    color: white;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}

.tr-btn-primary:hover:not(:disabled) {
    background: #7c3aed;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(139, 92, 246, 0.5);
}

.tr-btn-success {
    background: #10b981;
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.tr-btn-success:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-1px);
}

.tr-btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.tr-btn-danger:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.5);
}

.tr-btn-ghost {
    background: rgba(255,255,255,0.12);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(8px);
}

.tr-btn-ghost:hover:not(:disabled) {
    background: rgba(255,255,255,0.22);
    transform: translateY(-1px);
}

.tr-btn-outline {
    background: transparent;
    color: #6d28d9;
    border: 2px solid #8b5cf6;
}

.tr-btn-outline:hover:not(:disabled) {
    background: #8b5cf6;
    color: white;
}

/* --- FILTER BAR --- */
.tr-filter-bar {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    background: white;
    border-radius: 16px;
    margin: 0 24px 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    border: 1px solid #e2e8f0;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
}

.tr-filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 0 1 220px;
    min-width: 150px;
}

.tr-filter-group label {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tr-select {
    padding: 9px 14px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.tr-select:focus {
    outline: none;
    border-color: #8b5cf6;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.tr-filter-action {
    display: flex;
    align-items: flex-end;
    padding-bottom: 0;
}

/* --- KPI CARDS --- */
.tr-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: 16px;
    padding: 0 24px 24px;
}

.tr-kpi-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    border: 1px solid #e2e8f0;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.tr-kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 28px rgba(0,0,0,0.1);
}

.tr-kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    border-radius: 16px 16px 0 0;
}

.tr-kpi-card.blue::before { background: linear-gradient(90deg, #3b82f6, #6366f1); }
.tr-kpi-card.green::before { background: linear-gradient(90deg, #10b981, #34d399); }
.tr-kpi-card.amber::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.tr-kpi-card.red::before { background: linear-gradient(90deg, #ef4444, #f87171); }
.tr-kpi-card.purple::before { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }

.tr-kpi-icon {
    font-size: 28px;
    margin-bottom: 10px;
    display: block;
}

.tr-kpi-label {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.tr-kpi-value {
    font-size: 30px;
    font-weight: 900;
    color: #1e293b;
    line-height: 1;
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}

.tr-kpi-sub {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

.tr-kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    margin-top: 4px;
}

.tr-kpi-trend.up { background: #dcfce7; color: #16a34a; }
.tr-kpi-trend.down { background: #fee2e2; color: #dc2626; }
.tr-kpi-trend.neutral { background: #f1f5f9; color: #64748b; }

/* --- CONTENT GRID --- */
.tr-content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding: 0 24px 24px;
}

@media (max-width: 1100px) {
    .tr-content-grid {
        grid-template-columns: 1fr;
    }
}

/* --- PANEL CARD --- */
.tr-panel {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.tr-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid #f1f5f9;
    background: #fafbff;
}

.tr-panel-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
}

.tr-panel-body {
    padding: 4px 0;
}

/* --- STUDENT TABLE --- */
.tr-table-wrapper {
    overflow-x: visible;
}
@media (max-width: 900px) { .tr-table-wrapper { overflow-x: auto; } }

.tr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.tr-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.tr-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

.tr-table tbody tr:last-child {
    border-bottom: none;
}

.tr-table tbody tr:hover {
    background: #fafaff;
}

.tr-table td {
    padding: 11px 16px;
    color: #374151;
    vertical-align: middle;
}

.tr-table .tr-rank {
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
    width: 36px;
}

.tr-table .tr-rank.gold { color: #f59e0b; }
.tr-table .tr-rank.silver { color: #6b7280; }
.tr-table .tr-rank.bronze { color: #b45309; }

.tr-student-name {
    font-weight: 600;
    color: #1e293b;
}

.tr-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.tr-badge-grade {
    background: #ede9fe;
    color: #6d28d9;
}

.tr-net-val {
    font-weight: 700;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.tr-net-high { color: #10b981; }
.tr-net-mid { color: #f59e0b; }
.tr-net-low { color: #ef4444; }

.tr-trend-icon {
    font-size: 16px;
    font-weight: 700;
}

.tr-risk-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.tr-risk-green { background: #10b981; box-shadow: 0 0 6px rgba(16,185,129,0.5); }
.tr-risk-yellow { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.5); }
.tr-risk-red { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,0.5); }

/* --- KAZANIM LIST --- */
.tr-kazanim-list {
    list-style: none;
    margin: 0;
    padding: 12px 0;
}

.tr-kazanim-item {
    padding: 12px 22px;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

.tr-kazanim-item:last-child { border-bottom: none; }
.tr-kazanim-item:hover { background: #fafaff; }

.tr-kazanim-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.tr-kazanim-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    flex: 1;
    margin-right: 10px;
}

.tr-kazanim-pct {
    font-size: 12px;
    font-weight: 800;
    color: #ef4444;
    white-space: nowrap;
}

.tr-kazanim-bar-bg {
    height: 6px;
    background: #f1f5f9;
    border-radius: 10px;
    overflow: hidden;
}

.tr-kazanim-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.tr-kazanim-bar-fill.medium {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.tr-kazanim-bar-fill.low {
    background: linear-gradient(90deg, #10b981, #34d399);
}

/* --- CHART AREA --- */
.tr-chart-wrap {
    padding: 16px 20px 20px;
    position: relative;
}

.tr-chart-wrap canvas {
    max-height: 240px;
}

/* --- HESAP SOR MODAL --- */
.tr-accountability-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    backdrop-filter: blur(4px);
    animation: tr-overlay-in 0.2s ease;
}

@keyframes tr-overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tr-accountability-modal {
    background: white;
    border-radius: 20px;
    max-width: 680px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0,0,0,0.4);
    animation: tr-modal-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tr-modal-in {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.tr-modal-header {
    background: linear-gradient(135deg, #1e1b4b, #4c1d95);
    color: white;
    padding: 24px 28px;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.tr-modal-header h3 {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 800;
}

.tr-modal-header p {
    margin: 0;
    font-size: 13px;
    opacity: 0.7;
}

.tr-modal-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    margin-left: 16px;
}

.tr-modal-close:hover {
    background: rgba(255,255,255,0.25);
}

.tr-modal-body {
    padding: 24px 28px;
}

.tr-accountability-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.tr-acc-stat {
    background: #f8fafc;
    border-radius: 12px;
    padding: 14px;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.tr-acc-stat-val {
    font-size: 24px;
    font-weight: 900;
    color: #1e293b;
}

.tr-acc-stat-lbl {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
    margin-top: 3px;
}

.tr-weakness-section {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.tr-weakness-section h4 {
    margin: 0 0 10px;
    font-size: 13px;
    color: #dc2626;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tr-weakness-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tr-weakness-tag {
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #fca5a5;
}

.tr-note-section {
    margin-bottom: 20px;
}

.tr-note-section label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 8px;
}

.tr-note-textarea {
    width: 100%;
    min-height: 100px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    color: #1e293b;
    resize: vertical;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.tr-note-textarea:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.tr-modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 28px 24px;
    border-top: 1px solid #f1f5f9;
    flex-wrap: wrap;
}

/* --- EMPTY STATE --- */
.tr-empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #94a3b8;
}

.tr-empty-state .tr-empty-icon {
    font-size: 52px;
    margin-bottom: 16px;
    display: block;
    opacity: 0.6;
}

.tr-empty-state p {
    font-size: 14px;
    margin: 0;
    line-height: 1.6;
}

/* --- LOADING SPINNER --- */
.tr-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 56px 24px;
    gap: 16px;
    color: #8b5cf6;
}

.tr-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #ede9fe;
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: tr-spin 0.8s linear infinite;
}

@keyframes tr-spin {
    to { transform: rotate(360deg); }
}

.tr-loading p {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #6d28d9;
}

/* --- FULL WIDTH PANEL --- */
.tr-full-panel {
    grid-column: 1 / -1;
}

/* --- SECTION DIVIDER --- */
.tr-divider {
    padding: 0 24px 20px;
}

.tr-divider-line {
    height: 1px;
    background: linear-gradient(90deg, transparent, #e2e8f0, transparent);
}

/* --- DARK MODE SUPPORT --- */
@media (prefers-color-scheme: dark) {
    .tr-filter-bar, .tr-panel, .tr-kpi-card, .tr-acc-stat {
        background: #1e293b;
        border-color: #334155;
    }
    .tr-table thead th { background: #0f172a; color: #94a3b8; }
    .tr-table tbody tr:hover { background: #0f172a; }
    .tr-table td, .tr-student-name { color: #e2e8f0; }
    .tr-kpi-value, .tr-panel-header h3 { color: #f1f5f9; }
    .tr-select { background-color: #0f172a; color: #e2e8f0; border-color: #334155; }
    .tr-panel-header { background: #0f172a; }
    .tr-kazanim-bar-bg { background: #334155; }
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .tr-header { padding: 20px 16px 18px; border-radius: 0; }
    .tr-filter-bar { margin: 0 12px 16px; padding: 14px; }
    .tr-kpi-grid { padding: 0 12px 16px; }
    .tr-content-grid { padding: 0 12px 16px; }
    .tr-kpi-card { padding: 16px; }
    .tr-kpi-value { font-size: 24px; }
    .tr-accountability-stats { grid-template-columns: repeat(2, 1fr); }
}


/* ============================================================
   v1.1 — Düzen iyileştirmesi: tam genişlik tablo, ortalanmış ve ferah kartlar
   ============================================================ */
.tr-content-grid { gap: 24px; max-width: 1500px; margin: 0 auto; }

/* Tablo: kaydırma çubuğu olmadan sığsın */
.tr-table { table-layout: auto; font-size: 13px; }
.tr-table thead th { padding: 12px 12px; text-align: center; white-space: normal; line-height: 1.3; }
.tr-table thead th:nth-child(2) { text-align: left; }
.tr-table td { padding: 11px 12px; text-align: center; }
.tr-table td:nth-child(2) { text-align: left; }
.tr-table-wrapper { padding: 8px 16px 14px; }

/* Alt kartlar: yan yana, geniş aralıklı */
.tr-secondary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
    gap: 24px;
    align-items: start;
}
.tr-secondary-grid > .tr-insight-panel,
.tr-secondary-grid > .tr-kazanim-panel { grid-column: 1 / -1; }
@media (max-width: 560px) { .tr-secondary-grid { grid-template-columns: minmax(0, 1fr); } }

.tr-panel-header { padding: 18px 26px; }
.tr-panel-body { padding: 18px 26px 22px; }
.tr-table-wrapper.tr-panel-body { padding: 8px 16px 14px; }

/* Destek ve Gelişim: iki ayrı kart sütunu */
.tr-insight-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}
.tr-insight-col {
    border-radius: 14px;
    padding: 18px 22px 20px;
    border: 1px solid #e2e8f0;
}
.tr-insight-support { background: #fffbeb; border-color: #fde68a; }
.tr-insight-improving { background: #ecfdf5; border-color: #a7f3d0; }
.tr-insight-col h4 {
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 800;
    text-align: center;
}
.tr-insight-support h4 { color: #b45309; }
.tr-insight-improving h4 { color: #047857; }
.tr-insight-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tr-insight-item {
    background: rgba(255,255,255,0.75);
    border-radius: 10px;
    padding: 10px 14px;
    text-align: center;
}
.tr-insight-name { font-size: 13.5px; color: #1e293b; }
.tr-insight-grade { color: #94a3b8; font-size: 12px; margin-left: 4px; }
.tr-insight-text { font-size: 12px; color: #64748b; margin-top: 3px; line-height: 1.5; }
.tr-insight-empty, .tr-insight-more { text-align: center; color: #94a3b8; font-size: 12.5px; padding: 6px 0; }

/* Kazanımlar: iki sütun, ferah satırlar */
.tr-kazanim-note { font-size: 12px; color: #64748b; text-align: center; margin-bottom: 14px; }
.tr-kazanim-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 14px;
    padding: 0;
}
.tr-kazanim-item {
    padding: 14px 18px;
    border: 1px solid #f1f5f9;
    border-radius: 12px;
    background: #fcfcff;
}
.tr-kazanim-item:last-child { border-bottom: 1px solid #f1f5f9; }
.tr-kazanim-top { margin-bottom: 9px; gap: 10px; }
.tr-kazanim-advice { font-size: 12px; color: #64748b; margin-top: 8px; line-height: 1.5; }
@media (max-width: 560px) { .tr-kazanim-list { grid-template-columns: minmax(0, 1fr); } }

@media (prefers-color-scheme: dark) {
    .tr-insight-support { background: #3a2f12; border-color: #78560f; }
    .tr-insight-improving { background: #0f3327; border-color: #14664b; }
    .tr-insight-item { background: rgba(15,23,42,0.5); }
    .tr-insight-name { color: #e2e8f0; }
    .tr-kazanim-item { background: #0f172a; border-color: #334155; }
}
