/**
 * Starlit-tempmail — duyarlı düzen katmanı
 *
 * Sorumluluk: Görünür yükseklik (dvh) düzeltmesi ve tablet/mobil kırılma noktaları.
 * Diğer tüm kuralları geçersiz kılabilmesi için EN SON yüklenir.
 *
 * Yükleme sırası önemlidir: CSS art arda uygulandığı için bu dosyalar
 * `inc/bootstrap.php` içinde base -> simple-view -> detail-view -> components
 * -> responsive sırasıyla kuyruğa alınır. Sıra değişirse geçersiz kılmalar bozulur.
 */

/* --- Yüksekliği tarayıcı çubuklarına dayanıklı hâle getir ---------------
   Mobilde 100vh, adres çubuğu gizlenip görününce zıplayan bir düzen üretir;
   dvh destekleyen tarayıcılarda gerçek görünür yükseklik kullanılır. */
@supports (height: 100dvh) {
    .starlit-tm-wrapper {
        height: 100dvh;
    }
}

/* --- Mobil uyum ---------------------------------------------------------- */
@media (max-width: 900px) {
    .starlit-tm-wrapper {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .starlit-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--starlit-border-silver);
    }

    .starlit-split-view {
        flex-direction: column;
    }

    .simple-email-preview-body {
        height: 320px;
    }
}

@media (max-width: 600px) {
    .starlit-main-header {
        height: auto;
        min-height: 60px;
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
        padding: 10px 16px;
    }

    .starlit-search-bar {
        grid-column: 1;
        justify-self: center;
        width: min(100%, 320px);
    }

    .starlit-actions-toolbar {
        grid-column: 1;
        justify-self: center;
    }

    #starlit-toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        max-width: none;
    }

    .simple-email-preview-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .starlit-image-warning-banner {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .starlit-image-warning-banner .starlit-btn {
        margin-left: 0;
    }
}

/* --- Telefon öncelikli düzen ------------------------------------------
   Bu kurallar sadece ölçüyü küçültmez; masaüstü satırlarını dokunma dostu
   kartlara dönüştürür. Böylece 320px genişlikte de yatay kaydırma oluşmaz. */
html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

button,
a,
input,
select {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

@media (max-width: 700px) {
    .starlit-simple-view {
        box-sizing: border-box;
        padding: max(14px, env(safe-area-inset-top)) 16px max(48px, env(safe-area-inset-bottom));
    }

    .starlit-simple-header {
        gap: 12px;
        padding: 10px 0 14px;
        margin-bottom: 34px;
        align-items: center;
    }

    .simple-brand-logo {
        font-size: clamp(18px, 6vw, 22px);
        letter-spacing: -0.35px;
    }

    .simple-header-links {
        gap: 8px;
        min-width: 0;
        flex-shrink: 0;
    }

    .simple-apps-label,
    .mock-app-btn {
        display: none;
    }

    .simple-header-links .theme-toggle-btn {
        min-height: 40px;
        margin-left: 0 !important;
        padding: 8px 10px;
    }

    .simple-logout-link {
        min-width: 40px;
        min-height: 40px;
        margin-left: 0 !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        font-size: 0 !important;
    }

    .simple-logout-link::before {
        content: '↪';
        font-size: 21px;
        line-height: 1;
    }

    .starlit-address-box-container {
        margin-bottom: 30px;
    }

    .address-box-title {
        font-size: 18px;
        margin-bottom: 14px;
    }

    .address-box-card {
        min-width: 0;
        padding: 14px;
        gap: 8px;
        border-radius: 14px;
    }

    .address-box-value {
        min-width: 0;
        font-size: clamp(16px, 5vw, 20px);
    }

    .address-box-icons {
        gap: 2px;
    }

    .icon-action-btn {
        min-width: 40px;
        min-height: 40px;
        padding: 8px;
    }

    .address-box-description {
        font-size: 14px;
        line-height: 1.65;
    }

    .address-box-description br {
        display: none;
    }

    .starlit-simple-toolbar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-bottom: 30px;
    }

    .starlit-simple-toolbar .starlit-btn {
        min-width: 0;
        min-height: 44px;
        padding: 10px 8px;
        justify-content: center;
    }

    .starlit-simple-toolbar .starlit-btn:last-child {
        grid-column: 1 / -1;
    }

    .simple-inbox-header {
        display: none;
    }

    .starlit-simple-inbox-card {
        margin-bottom: 38px;
        border-radius: 14px;
    }

    .simple-inbox-items {
        min-height: 220px;
    }

    .simple-inbox-row {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            'sender action'
            'subject action';
        gap: 5px 12px;
        padding: 15px 16px;
        min-height: 72px;
    }

    .simple-mail-sender {
        grid-area: sender;
        padding-right: 0;
    }

    .simple-mail-subject-group {
        grid-area: subject;
        min-width: 0;
    }

    .simple-mail-date {
        display: none;
    }

    .simple-mail-view-col {
        grid-area: action;
        align-self: center;
    }

    .simple-mail-view-col .starlit-btn,
    .simple-mail-view-btn {
        min-height: 40px;
        padding: 8px 12px;
    }

    .mail-list-empty-msg {
        min-height: 220px;
        height: auto;
        padding: 32px 16px;
    }

    .starlit-simple-description-section {
        margin-bottom: 38px;
    }

    .desc-title {
        font-size: 19px;
    }

    .desc-text {
        font-size: 14px;
        line-height: 1.7;
    }

    .footer-content {
        gap: 18px;
        text-align: center;
    }

    .footer-left,
    .footer-right {
        width: 100%;
        align-items: center;
    }

    /* Detaylı panel: kenar çubuğunu üstte yoğun bir kontrol bandına indir. */
    .starlit-tm-wrapper {
        min-width: 0;
    }

    .starlit-sidebar {
        box-sizing: border-box;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 12px;
        padding: 12px 16px;
    }

    .starlit-sidebar-header {
        display: none;
    }

    .starlit-mailbox-manager {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
        margin: 0;
    }

    .starlit-mailbox-manager .section-label {
        grid-column: 1 / -1;
        margin: 0;
    }

    .mailbox-selector-wrapper {
        margin: 0;
        min-width: 0;
    }

    .mailbox-actions-row,
    .starlit-sidebar-add-btn {
        width: auto;
    }

    .starlit-sidebar-add-btn {
        min-height: 42px;
        padding: 9px 12px;
        white-space: nowrap;
    }

    .starlit-folders {
        grid-column: 1 / -1;
        display: flex;
        gap: 6px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        margin: 0 -2px;
        padding: 2px;
        scrollbar-width: none;
    }

    .starlit-folders::-webkit-scrollbar {
        display: none;
    }

    .folder-item {
        flex: 0 0 auto;
        min-height: 40px;
        box-sizing: border-box;
        margin: 0;
        padding: 9px 11px;
        white-space: nowrap;
    }

    .folder-icon {
        margin-right: 6px;
    }

    .starlit-address-card {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px 10px;
        margin: 0;
        padding: 11px;
    }

    .starlit-address-card .address-label {
        grid-column: 1 / -1;
        margin: 0;
    }

    .address-value-container {
        align-self: center;
        margin: 0;
    }

    .address-actions-grid {
        width: auto;
        gap: 5px;
    }

    .starlit-card-action-btn {
        min-height: 38px;
        padding: 7px 8px !important;
    }

    .starlit-main {
        min-width: 0;
    }

    .starlit-main-header {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-rows: auto;
        gap: 8px;
        padding: 10px 16px;
    }

    .starlit-search-bar {
        grid-column: 1;
        justify-self: stretch;
        width: 100%;
        min-width: 0;
    }

    .starlit-actions-toolbar {
        grid-column: 2;
        justify-self: end;
        gap: 5px;
    }

    .starlit-topbar-btn,
    .starlit-topbar-back-btn {
        min-width: 40px !important;
        height: 40px !important;
    }

    .starlit-topbar-back-btn {
        padding: 0 !important;
        justify-content: center;
    }

    .starlit-topbar-back-btn span {
        display: none;
    }

    .starlit-split-view {
        display: flex;
        flex-direction: column;
        overflow: visible;
    }

    .starlit-pane-list {
        width: 100%;
        max-height: min(46dvh, 420px);
        border-right: 0;
        border-bottom: 1px solid var(--starlit-border-silver);
        flex-shrink: 0;
    }

    .starlit-pane-viewer {
        min-height: 54dvh;
    }

    .starlit-mail-item {
        padding: 14px 16px;
    }

    .viewer-header {
        gap: 14px;
        padding: 18px 16px;
        flex-direction: column;
    }

    .viewer-header-meta {
        max-width: 100%;
        min-width: 0;
    }

    .viewer-subject-text {
        font-size: 18px;
        overflow-wrap: anywhere;
    }

    .viewer-sender-email,
    .viewer-recipient-email {
        overflow-wrap: anywhere;
    }

    .viewer-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 7px;
    }

    .viewer-action-btn {
        min-height: 40px;
    }

    .simple-email-preview-body,
    .viewer-body {
        min-height: 360px;
    }
}

@media (max-width: 390px) {
    .simple-header-links .theme-toggle-text {
        display: none;
    }

    .simple-header-links .theme-toggle-btn {
        width: 40px;
        padding: 0;
        justify-content: center;
    }

    .starlit-simple-toolbar .starlit-btn {
        font-size: 12px;
    }

    .btn-label-icon {
        margin-right: 5px;
    }

    .mailbox-actions-row .starlit-sidebar-add-btn span {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
