/**
 * Öğretmen paneli — modül bazlı mobil düzen (≤1023px)
 * Web/masaüstü dokunulmaz; yalnızca touch-first iyileştirmeler.
 */
@media (max-width: 1023px) {
    /* —— Ortak: modül gövdesi —— */
    #teacher-panel main.flex-1 {
        padding-left: 0.35rem !important;
        padding-right: 0.35rem !important;
    }

    #teacher-panel .view-block:not(.hidden) {
        padding-top: 0.25rem !important;
        padding-bottom: 0.5rem !important;
    }

    #teacher-panel .tsh-module-hero {
        padding: 0.55rem 0.65rem !important;
        gap: 0.45rem !important;
        margin-bottom: 0.35rem !important;
    }

    #teacher-panel .tsh-module-hero-text h1 {
        font-size: 0.92rem !important;
    }

    #teacher-panel .tsh-module-hero-text p {
        font-size: 0.62rem !important;
        line-height: 1.35 !important;
    }

    #teacher-panel .tsh-module-hero-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.32rem !important;
    }

    #teacher-panel .tsh-module-kpi {
        padding: 0.32rem 0.38rem !important;
    }

    #teacher-panel .tsh-module-kpi strong {
        font-size: 0.82rem !important;
    }

    #teacher-panel .tsh-module-kpi span {
        font-size: 0.52rem !important;
    }

    /* —— MESAJLAR: tam ekran liste ↔ sohbet —— */
    #messages-view:not(.hidden) {
        height: auto !important;
        max-height: none !important;
        padding: 0 !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
    }

    #messages-view:not(.hidden) .wa-shell {
        border-radius: 0.65rem !important;
        min-height: 0 !important;
        height: 100% !important;
    }

    #messages-view:not(.hidden) .wa-layout {
        grid-template-columns: 1fr !important;
        grid-template-rows: 1fr !important;
        min-height: 0 !important;
        height: 100% !important;
    }

    #messages-view:not(.hidden) .wa-rail {
        max-height: none !important;
        height: 100% !important;
        border-right: none !important;
    }

    #messages-view.is-tmsg-thread .wa-rail,
    #messages-view .wa-shell.is-thread-open .wa-rail {
        display: none !important;
    }

    #messages-view:not(.is-tmsg-thread) .wa-stage,
    #messages-view .wa-shell:not(.is-thread-open) .wa-stage {
        display: none !important;
    }

    #messages-view.is-tmsg-thread .wa-stage,
    #messages-view .wa-shell.is-thread-open .wa-stage {
        display: flex !important;
        height: 100% !important;
        min-height: 0 !important;
    }

    #messages-view:not(.is-tmsg-thread) .wa-rail,
    #messages-view .wa-shell:not(.is-thread-open) .wa-rail {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        min-height: 0 !important;
    }

    #messages-view .wa-rail-top {
        padding: 0.55rem 0.65rem !important;
    }

    #messages-view .wa-rail-title {
        font-size: 0.95rem !important;
    }

    #messages-view .wa-search-wrap {
        margin: 0 0.5rem 0.35rem !important;
    }

    #messages-view .wa-search-wrap input {
        font-size: 0.78rem !important;
        min-height: 2.1rem !important;
    }

    #messages-view .wa-person {
        min-height: 3.1rem !important;
        padding: 0.45rem 0.55rem !important;
        touch-action: manipulation;
    }

    #messages-view .wa-person-name {
        font-size: 0.8rem !important;
    }

    #messages-view .wa-person-preview {
        font-size: 0.68rem !important;
    }

    #messages-view .wa-stage-head {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 0.35rem !important;
        padding: 0.28rem 0.45rem !important;
        min-height: 2.65rem !important;
        max-height: 2.85rem !important;
        box-sizing: border-box !important;
    }

    #messages-view .tmsg-mobile-back {
        display: inline-flex !important;
        width: 1.75rem !important;
        height: 1.75rem !important;
        flex-shrink: 0 !important;
        margin: 0 !important;
    }

    #messages-view .wa-typing-banner {
        display: none !important;
    }

    #messages-view .wa-stage-peer {
        display: flex !important;
        align-items: center !important;
        gap: 0.4rem !important;
        min-width: 0 !important;
        flex: 1 1 auto !important;
    }

    #messages-view .wa-stage-actions {
        display: grid !important;
        grid-template-columns: repeat(2, 1.55rem) !important;
        gap: 0.12rem !important;
        flex: 0 0 auto !important;
        margin-left: auto !important;
        align-self: center !important;
    }

    #messages-view .wa-stage-actions .wa-icon-btn {
        width: 1.55rem !important;
        height: 1.55rem !important;
        min-width: 1.55rem !important;
        font-size: 0.62rem !important;
        padding: 0 !important;
    }

    #messages-view .tmsg-avatar-btn .wa-avatar,
    #messages-view .wa-avatar {
        width: 1.85rem !important;
        height: 1.85rem !important;
        font-size: 0.65rem !important;
    }

    #messages-view .tmsg-peer-text {
        min-width: 0 !important;
        flex: 1 1 auto !important;
    }

    #messages-view .tmsg-peer-text strong {
        font-size: 0.82rem !important;
        line-height: 1.15 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: block !important;
        max-width: 100% !important;
    }

    #messages-view .wa-stage-head .wa-peer-meta {
        font-size: 0.58rem !important;
        margin-top: 0 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
    }

    #messages-view .wa-peer-typing {
        display: none !important;
    }

    #messages-view .wa-composer {
        padding: 0.35rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom, 0px)) !important;
        background: #f0f2f5 !important;
    }

    #messages-view .tmsg-ai-quickbar,
    #messages-view #tmsg-ai-quickbar,
    #messages-view .mp-quick-replies {
        display: none !important;
        height: 0 !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        visibility: hidden !important;
    }

    #messages-view .wa-composer-inner {
        display: flex !important;
        align-items: flex-end !important;
        gap: 0.4rem !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    #messages-view .wa-attach-wrap {
        display: flex !important;
        align-items: center !important;
        align-self: center !important;
        flex-shrink: 0 !important;
    }

    #messages-view .wa-attach-btn,
    #messages-view .wa-send-btn {
        width: 2.35rem !important;
        height: 2.35rem !important;
        min-width: 2.35rem !important;
        min-height: 2.35rem !important;
        border-radius: 999px !important;
        flex-shrink: 0 !important;
        align-self: center !important;
        display: grid !important;
        place-items: center !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    #messages-view .wa-send-btn {
        background: #0f766e !important;
        color: #fff !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    #messages-view .wa-send-btn:disabled {
        opacity: 0.45 !important;
    }

    #messages-view .wa-send-btn i {
        font-size: 0.82rem !important;
        color: #fff !important;
        line-height: 1 !important;
    }

    #messages-view #chat-input-text,
    #messages-view .wa-composer-inner textarea,
    #messages-view .wa-composer-inner input {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        width: auto !important;
        max-width: 100% !important;
        font-size: 0.92rem !important;
        min-height: 2.35rem !important;
        max-height: 6.5rem !important;
        height: auto !important;
        padding: 0.55rem 0.85rem !important;
        border-radius: 1.1rem !important;
        box-sizing: border-box !important;
        background: #fff !important;
        resize: none !important;
        line-height: 1.35 !important;
        overflow-y: auto !important;
        align-self: center !important;
    }

    #messages-view .wa-rail-top {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 0.3rem 0.4rem !important;
        padding: 0.35rem 0.5rem !important;
    }

    #messages-view .wa-rail-title {
        font-size: 0.9rem !important;
        margin: 0 !important;
        flex: 1 1 auto !important;
    }

    #messages-view .wa-search-wrap {
        flex: 1 1 calc(100% - 5.5rem) !important;
        min-width: 0 !important;
        margin: 0 !important;
        order: 3 !important;
    }

    #messages-view .wa-search-wrap input {
        font-size: 0.75rem !important;
        min-height: 1.85rem !important;
        padding: 0.28rem 0.55rem 0.28rem 1.7rem !important;
    }

    #messages-view .wa-rail-top > .wa-icon-btn,
    #messages-view #tmsg-watch-btn {
        order: 2 !important;
        width: 1.85rem !important;
        height: 1.85rem !important;
        min-width: 1.85rem !important;
        flex-shrink: 0 !important;
    }

    #messages-view .wa-rail-filters {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 0.22rem !important;
        padding: 0.15rem 0.45rem 0.3rem !important;
        overflow-x: auto !important;
        scrollbar-width: none;
    }

    #messages-view .wa-filter-chip {
        flex: 0 0 auto !important;
        font-size: 0.64rem !important;
        font-weight: 800 !important;
        padding: 0.22rem 0.48rem !important;
        min-height: 0 !important;
        line-height: 1.15 !important;
        border-radius: 999px !important;
    }

    #messages-view .mp-status-rail {
        padding: 0.12rem 0.45rem 0.28rem !important;
    }

    #messages-view .mp-status-avatar {
        width: 1.85rem !important;
        height: 1.85rem !important;
        font-size: 0.55rem !important;
    }

    #messages-view .wa-thread {
        padding: 0.45rem 3% !important;
    }

    #messages-view .wa-bubble {
        font-size: 0.78rem !important;
        line-height: 1.4 !important;
    }

    #tmsg-ai-drawer {
        padding-top: var(--mp-safe-top, 36px) !important;
        align-items: stretch !important;
        box-sizing: border-box !important;
    }

    #tmsg-ai-drawer .tmsg-ai-drawer-panel {
        height: calc(100% - 0px) !important;
        max-height: 100% !important;
        padding-top: 0 !important;
    }

    #tmsg-ai-drawer .tmsg-ai-drawer-head {
        padding-top: 0.65rem !important;
    }

    /* —— AJANDA —— */
    #teacher-panel #agenda-view .agenda-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.4rem !important;
    }

    #teacher-panel #agenda-view .agenda-view-tabs {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 0.25rem !important;
    }

    #teacher-panel #agenda-view .agenda-tab {
        font-size: 0.58rem !important;
        padding: 0.38rem 0.2rem !important;
        min-height: 2.2rem !important;
    }

    #teacher-panel #agenda-view .agenda-tab i {
        font-size: 0.72rem !important;
    }

    #teacher-panel #agenda-view .agenda-nav {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 0.28rem !important;
    }

    #teacher-panel #agenda-view .agenda-nav-label {
        font-size: 0.72rem !important;
        min-width: 0 !important;
        flex: 1 1 auto !important;
        text-align: center;
    }

    /* —— DUYURULAR & ANKETLER —— */
    #teacher-panel #announcements-view .announce-toolbar,
    #teacher-panel #polls-view .poll-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.45rem !important;
    }

    #teacher-panel #announcements-view .announce-title,
    #teacher-panel #polls-view .poll-title {
        font-size: 0.95rem !important;
    }

    #teacher-panel #announcements-view .announce-btn,
    #teacher-panel #polls-view .poll-btn {
        width: 100% !important;
        justify-content: center !important;
        min-height: 2.35rem !important;
        font-size: 0.75rem !important;
    }

    #teacher-panel .announce-board-wrap,
    #teacher-panel .poll-list-wrap {
        padding: 0.25rem 0 !important;
    }

    /* —— ÖDEV ATAMALARI —— */
    #teacher-panel #homework-view .hw-toolbar,
    #teacher-panel #homework-view .hw-form-grid {
        grid-template-columns: 1fr !important;
    }

    #teacher-panel #homework-view .hw-weekly-grid {
        grid-template-columns: 1fr !important;
    }

    /* —— PERFORMANS / KONULAR / TESTLER —— */
    #teacher-panel #exams-view .exam-folder-grid,
    #teacher-panel #topics-view .topics-unit-grid,
    #teacher-panel #tests-view .tests-layout,
    #teacher-panel #tests-view .tests-results-split,
    #teacher-panel #missed-questions-view .mq-subject-grid {
        grid-template-columns: 1fr !important;
        gap: 0.45rem !important;
    }

    #teacher-panel #exams-view .tdash-card,
    #teacher-panel #topics-view .tdash-card,
    #teacher-panel #tests-view .tdash-card {
        padding: 0.55rem 0.6rem !important;
    }

    /* —— KÜTÜPHANE —— */
    #teacher-panel #teacher-library-view .tdash-library-hero {
        grid-template-columns: 1fr !important;
        gap: 0.4rem !important;
    }

    #teacher-panel #teacher-library-view .tdash-library-card {
        min-height: 0 !important;
        padding: 0.55rem 0.65rem !important;
    }

    /* —— OYUN SIRALAMASI —— */
    #teacher-panel #game-scores-view {
        padding-left: 0.35rem !important;
        padding-right: 0.35rem !important;
    }

    #teacher-panel #game-scores-view .tgl-play-panel {
        padding: 0.65rem 0.7rem !important;
        border-radius: 0.85rem !important;
    }

    #teacher-panel #game-scores-view .tgl-play-head h3 {
        font-size: 0.78rem !important;
    }

    #teacher-panel #game-scores-view .tgl-play-head p {
        font-size: 0.62rem !important;
    }

    #teacher-panel #game-scores-view .tgl-play-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.35rem !important;
        margin-top: 0.55rem !important;
    }

    #teacher-panel #game-scores-view .tgl-play-card {
        padding: 0.5rem 0.55rem !important;
    }

    #teacher-panel #game-scores-view .tgl-play-card strong {
        font-size: 0.62rem !important;
    }

    /* —— Z RAPORU —— */
    #teacher-panel #z-report-view .z-report-cards-grid {
        grid-template-columns: 1fr !important;
    }

    #teacher-panel #z-report-view .z-report-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.4rem !important;
    }

    #teacher-panel #z-report-view .z-report-toolbar input,
    #teacher-panel #z-report-view .z-report-toolbar select {
        width: 100% !important;
        min-height: 2.2rem !important;
        font-size: 0.75rem !important;
    }

    #teacher-panel #mentor-alarms-view .malarm-hub-tabs {
        gap: 0.25rem !important;
    }

    #teacher-panel #mentor-alarms-view .malarm-hub-tab {
        font-size: 0.58rem !important;
        padding: 0.4rem 0.35rem !important;
    }

    #teacher-panel #mentor-alarms-view .malarm-student-foot,
    #teacher-panel #mentor-alarms-view .malarm-archive-foot {
        flex-direction: column !important;
    }

    #teacher-panel #mentor-alarms-view .malarm-foot-btn {
        width: 100% !important;
    }

    /* —— BİLDİRİMLER / DOĞUM GÜNLERİ / MENTOR ALARMLARI —— */
    #teacher-panel #notifications-view .notif-hub-grid,
    #teacher-panel #birthdays-view .bb-notes-grid,
    #teacher-panel #mentor-alarms-view .malarm-grid {
        grid-template-columns: 1fr !important;
    }

    #teacher-panel #notifications-view .notif-card,
    #teacher-panel #birthdays-view .bb-card,
    #teacher-panel #mentor-alarms-view .malarm-card {
        padding: 0.55rem 0.6rem !important;
    }

    /* —— SÜTLAÇ AI —— */
    #teacher-panel #teacher-ai-view .tai-layout {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0.65rem !important;
        min-height: 0 !important;
    }

    #teacher-panel #teacher-ai-view .tai-sidebar {
        display: none !important;
    }

    #teacher-panel #teacher-ai-view .tai-usage-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.4rem !important;
    }

    #teacher-panel #teacher-ai-view .tai-usage-kpi {
        padding: 0.5rem 0.55rem !important;
        min-width: 0 !important;
    }

    #teacher-panel #teacher-ai-view .tai-usage-kpi strong {
        font-size: 0.95rem !important;
    }

    #teacher-panel #teacher-ai-view .tai-usage-kpi em {
        font-size: 0.62rem !important;
        white-space: normal !important;
        line-height: 1.25 !important;
    }

    #teacher-panel #teacher-ai-view .tai-hero {
        flex-direction: column !important;
        text-align: left !important;
        padding: 0.75rem !important;
        gap: 0.55rem !important;
    }

    #teacher-panel #teacher-ai-view .tai-hero-visual img {
        width: 52px !important;
        height: 52px !important;
    }

    #teacher-panel #teacher-ai-view .tai-hero-copy h2 {
        font-size: 1.05rem !important;
    }

    #teacher-panel #teacher-ai-view .tai-panel {
        display: flex !important;
        flex-direction: column !important;
        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;
        padding: 0.7rem !important;
    }

    #teacher-panel #teacher-ai-view .tai-thread,
    #teacher-panel #teacher-ai-view .tai-messages {
        flex: 1 1 auto !important;
        min-height: 10rem !important;
        max-height: 42dvh !important;
        overflow-y: auto !important;
    }

    #teacher-panel #teacher-ai-view .tai-compose {
        display: flex !important;
        gap: 0.4rem !important;
        width: 100% !important;
        min-width: 0 !important;
        flex-shrink: 0 !important;
    }

    #teacher-panel #teacher-ai-view .tai-compose input,
    #teacher-panel #teacher-ai-view .tai-compose textarea {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        font-size: 0.92rem !important;
        box-sizing: border-box !important;
    }

    #teacher-panel #teacher-ai-view .tai-usage-grid,
    #teacher-panel #teacher-ai-view .tai-charts,
    #teacher-panel #teacher-ai-view .tai-track {
        grid-template-columns: 1fr !important;
    }

    #teacher-panel #teacher-ai-view .tai-topic-row span {
        min-width: 0 !important;
        flex: 0 0 5.5rem;
    }

    /* —— ÖĞRENCİLER —— */
    #teacher-panel #all-students-view .s360-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.35rem !important;
    }

    #teacher-panel #all-students-view .s360-toolbar input,
    #teacher-panel #all-students-view .s360-toolbar select,
    #teacher-panel #all-students-view .s360-toolbar button {
        width: 100% !important;
        min-height: 2.2rem !important;
        font-size: 0.72rem !important;
    }

    /* —— Dokunma hedefleri —— */
    #teacher-panel .view-block button,
    #teacher-panel .view-block .tdash-nav-item,
    #teacher-panel .view-block a[role="button"] {
        touch-action: manipulation;
    }

    #teacher-panel .view-block :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]) {
        font-size: max(0.72rem, 16px); /* iOS zoom önleme alt sınırı yakın */
    }

    /* —— GOOGLE DRIVE —— */
    #teacher-panel #drive-sync-view .gdrv-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    #teacher-panel #drive-sync-view .gdrv-sync-status {
        margin-left: 0 !important;
        text-align: center;
    }

    #teacher-panel #drive-sync-view .gdrv-status-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    #teacher-panel #drive-sync-view .gdrv-head-actions {
        width: 100%;
    }

    #teacher-panel #drive-sync-view .gdrv-head-actions .gdrv-btn {
        flex: 1;
        justify-content: center;
    }
}

@media (min-width: 1024px) {
    #messages-view .tmsg-mobile-back {
        display: none !important;
    }
}
