/* =========================================================
   İKRA SOSYAL MEDIA MANAGER — MOBILE APPLICATION LAYER
   Masaüstü arayüzüne dokunmaz.
   ========================================================= */

.mobile-app-bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    :root {
        --mobile-app-header-height: 58px;
        --mobile-app-nav-height: calc(64px + env(safe-area-inset-bottom));
        --mobile-app-radius: 16px;
        --mobile-app-touch: 44px;
    }

    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    body.app-body {
        min-width: 0;
        overflow-x: hidden;
        background: color-mix(in srgb, var(--surface-soft) 70%, var(--surface));
        overscroll-behavior-y: none;
        -webkit-tap-highlight-color: transparent;
    }

    body.app-body.mobile-keyboard-open .mobile-app-bottom-nav {
        display: none !important;
    }

    .app-main {
        width: 100%;
        min-width: 0;
        margin-left: 0 !important;
    }

    #api-post-modal-title{
        display: none;
    }

    .page-content {
        width: 100%;
        min-width: 0;
        padding: 10px 10px calc(var(--mobile-app-nav-height) + 14px);
    }

    /* Android benzeri app bar */
    .mobile-header {
        position: sticky;
        z-index: 9500;
        top: 0;
        min-height: calc(var(--mobile-app-header-height) + env(safe-area-inset-top));
        display: grid !important;
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        align-items: end;
        gap: 5px;
        padding: env(safe-area-inset-top) 7px 0;
        border-bottom: 1px solid var(--border);
        background: color-mix(in srgb, var(--surface) 96%, transparent);
        box-shadow: 0 3px 16px rgba(15, 23, 42, .055);
        backdrop-filter: blur(16px);
    }

    .mobile-header > .icon-btn {
        width: 44px;
        height: 50px;
        min-height: 50px;
        border: 0;
        border-radius: 13px;
    }

    .mobile-header-context {
        min-width: 0;
        min-height: 50px;
        display: grid;
        align-content: center;
        gap: 1px;
        text-align: center;
    }

    .mobile-header-context strong {
        overflow: hidden;
        color: var(--text);
        font-size: 14px;
        font-weight: 850;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-header-context small {
        overflow: hidden;
        color: var(--muted);
        font-size: 10px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Sidebar = navigation drawer */
    .sidebar {
        z-index: 12000 !important;
        width: min(88vw, 315px) !important;
        max-width: 348px;
        padding-bottom: env(safe-area-inset-bottom);
        border-right: 1px solid var(--border);
        box-shadow: 16px 0 55px rgba(15, 23, 42, .2);
    }

    .mobile-sidebar-backdrop,
    #sidebar-backdrop {
        z-index: 11900 !important;
        background: rgba(15, 23, 42, .45);
        backdrop-filter: blur(2px);
    }

    .sidebar-brand {
        min-height: 66px;
        padding-top: env(safe-area-inset-top);
    }

    .sidebar-link {
        min-height: 48px;
        border-radius: 12px;
        font-size: 13px;
    }

    .sidebar-link svg {
        width: 20px;
        height: 20px;
    }

    .nav-group-label {
        margin-top: 10px;
        font-size: 9px;
        letter-spacing: .06em;
    }

    /* Bottom navigation */
    .mobile-app-bottom-nav {
        position: fixed;
        z-index: 9400;
        right: 0;
        bottom: 0;
        left: 0;
        min-height: var(--mobile-app-nav-height);
        display: grid;
        grid-template-columns: repeat(var(--mobile-nav-count, 5), minmax(0, 1fr));
        align-items: start;
        padding: 5px 4px env(safe-area-inset-bottom);
        border-top: 1px solid var(--border);
        background: color-mix(in srgb, var(--surface) 97%, transparent);
        box-shadow: 0 -8px 25px rgba(15, 23, 42, .075);
        backdrop-filter: blur(18px);
    }

    .mobile-app-bottom-nav a,
    .mobile-app-bottom-nav button {
        min-width: 0;
        min-height: 55px;
        display: grid;
        place-items: center;
        align-content: center;
        gap: 3px;
        padding: 4px 1px;
        border: 0;
        border-radius: 12px;
        background: transparent;
        color: var(--muted);
        font: inherit;
        text-decoration: none;
        cursor: pointer;
    }

    .mobile-app-bottom-nav i { font-size: 18px; }

    .mobile-app-bottom-nav span {
        max-width: 100%;
        overflow: hidden;
        font-size: 9px;
        font-weight: 750;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-app-bottom-nav :is(a, button).active {
        color: var(--primary-text);
        background: color-mix(in srgb, var(--primary) 8%, transparent);
    }

    /* Android touch / typography */
    body.app-body :is(input, select, textarea) {
        font-size: 16px;
    }

    body.app-body :is(
        input:not([type="checkbox"]):not([type="radio"]),
        select,
        .btn
    ) {
        min-height: var(--mobile-app-touch);
    }

    body.app-body textarea { line-height: 1.5; }
    body.app-body .icon-btn { min-width: 40px; min-height: 40px; }

    :is(
        .panel,
        .card,
        .api-section,
        .statistics-panel,
        .stats-panel,
        .api-platform-card,
        .calendar-shell,
        .api-calendar-shell
    ) {
        border-radius: var(--mobile-app-radius);
    }

    /* Planner top tabs */
    .api-planner-shell { min-width: 0; }

    .api-main-tabs {
        position: sticky;
        z-index: 9200;
        top: calc(var(--mobile-app-header-height) + env(safe-area-inset-top));
        min-width: 0;
        display: block;
        margin: -10px -10px 10px;
        padding: 0 9px;
        border-bottom: 1px solid var(--border);
        background: color-mix(in srgb, var(--surface) 97%, transparent);
        backdrop-filter: blur(14px);
    }

    .api-main-tabs > span {
        width: 100%;
        display: flex;
        overflow-x: auto;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
    }

    .api-main-tabs > span::-webkit-scrollbar { display: none; }

    .api-main-tabs > span > a {
        min-height: 41px;
        flex: 0 0 auto;
        display: grid;
        place-items: center;
        padding: 0 13px;
        font-size: 11px;
        margin-bottom: 10px;
        scroll-snap-align: start;
    }

    .api-main-tabs .brand-selector--planner {
        width: 100%;
        max-width: none;
        margin: 7px 0 9px;
    }

    /* Custom selectors = bottom sheet */
    .brand-selector {
        --brand-selector-width: 100%;
        --brand-selector-menu-width: 100%;
    }

    .brand-selector-trigger { min-height: 48px; }

    .brand-selector-menu {
        margin: 0;
        position: fixed !important;
        z-index: 12500 !important;
        top: auto !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-width: none !important;
        max-height: min(calc(var(--mobile-visual-height, 100dvh) - 24px), 720px);
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 22px 22px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -18px 55px rgba(15, 23, 42, .22);
    }

    .brand-selector-search {
        position: sticky;
        z-index: 3;
        top: 0;
        background: var(--surface);
    }

    .brand-selector-menu[popover]:not(:popover-open) { display: none !important; }
    .brand-selector-menu::backdrop { background: rgba(15, 23, 42, .35); }
    .brand-selector-list {
        max-height: min(calc(var(--mobile-visual-height, 100dvh) - 260px), 600px);
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }
    .brand-selector-option { min-height: 54px; }

    /* Planlama listeleri */
    .api-planning-tabs {
        margin-right: -10px;
        margin-left: -10px;
        padding: 0 6px;
        scroll-snap-type: x proximity;
    }

    .api-planning-tabs a {
        min-height: 46px;
        display: grid;
        place-items: center;
        padding: 0 12px;
        font-size: 11px;
        scroll-snap-align: start;
    }

    .api-planning-list-toolbar {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .api-planning-search-field,
    .api-planning-date-trigger,
    .api-planning-platform-trigger,
    .api-planning-bulk-trigger,
    .api-planning-create-button {
        width: 100% !important;
        min-width: 0 !important;
    }

    .api-planning-date-popover,
    .api-planning-platform-menu,
    .api-planning-bulk-menu {
        position: fixed !important;
        z-index: 12600 !important;
        top: auto !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-width: none !important;
        max-height: 82dvh;
        overflow-y: auto;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 22px 22px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
        box-shadow: 0 -18px 55px rgba(15, 23, 42, .22);
    }

    .api-planning-date-popover { grid-template-columns: 1fr !important; }
    .api-planning-date-calendars { grid-template-columns: 1fr !important; padding-right: 0 !important; }
    .api-planning-date-calendar[data-planning-calendar-right] { display: none; }

    .api-planning-date-presets {
        padding-top: 10px !important;
        padding-left: 0 !important;
        border-top: 1px solid var(--border);
        border-left: 0 !important;
    }

    .api-planning-list-table-wrap {
        margin-right: -10px;
        margin-left: -10px;
        padding-right: 10px;
        padding-bottom: 7px;
        padding-left: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .api-planning-list-head,
    .api-planning-list-row {
        min-width: 850px;
    }

    .api-planning-pagination,
    .pagination {
        justify-content: flex-start !important;
        overflow-x: auto;
        padding: 7px 2px;
        scrollbar-width: none;
    }

    .api-planning-pagination::-webkit-scrollbar,
    .pagination::-webkit-scrollbar { display: none; }

    .api-planning-pagination a,
    .api-planning-pagination span,
    .pagination a,
    .pagination span {
        min-width: 40px;
        height: 40px;
        flex: 0 0 40px;
        border-radius: 12px;
        font-size: 11px;
    }

    /* Calendar */
    .api-calendar-shell {
        margin-right: -10px;
        margin-left: -10px;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

    .api-calendar-toolbar {
        gap: 7px;
        padding: 8px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .api-calendar-toolbar::-webkit-scrollbar { display: none; }
    .api-calendar-grid { min-width: 920px; }

    /* Statistics */
    .stats-header,
    .stats-channel-strip {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

    .stats-filter {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .stats-kpis,
    .stats-summary-grid,
    .stats-grid,
    .stats-grid--3,
    .stats-grid--equal {
        grid-template-columns: 1fr !important;
    }

    .stats-kpi { min-height: 104px; }

    .stats-table-wrap {
        margin-right: -10px;
        margin-left: -10px;
        padding-left: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .stats-table { min-width: 780px; }

    /* Generic tables */
    .table-wrap,
    .responsive-table,
    .admin-table-wrap {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Modals = bottom sheets; post modal = fullscreen */
    .modal-backdrop {
        align-items: flex-end !important;
        padding: 0 !important;
    }

.modal-dialog {
    /* width: 100% !important; */
    /* max-width: none !important; */
    /* max-height: 94dvh !important; */
    /* margin: 0 !important; */
    /* border-right: 0 !important; */
    /* border-bottom: 0 !important; */
    /* border-left: 0 !important; */
    /* border-radius: 7px 7px 0 0 !important; */
    padding-bottom: 60px;
    /* overflow-y: auto; */
}

    #api-post-modal .api-post-dialog {
        height: 100dvh;
        max-height: 100dvh !important;
        border-radius: 0 !important;
    }

    #api-post-modal .modal-header {
        position: sticky;
        z-index: 30;
        top: 0;
        padding-top: calc(9px + env(safe-area-inset-top));
        background: var(--surface);
    }

    .api-post-editor { grid-template-columns: 1fr !important; }
    .api-post-form-shell { min-height: 100%; }

    .form-grid-2,
    .form-grid-3,
    .form-grid-4 {
        grid-template-columns: 1fr !important;
    }

    .modal-footer {
        position: sticky;
        z-index: 20;
        bottom: 0;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
        background: var(--surface);
    }

    /* Snackbar */
    .toast-container,
    .api-inbox-toast {
        right: 10px !important;
        bottom: calc(var(--mobile-app-nav-height) + 10px) !important;
        left: 10px !important;
        width: auto !important;
        max-width: none !important;
    }
}

@media (max-width: 420px) {
    .page-content {
        padding-right: 7px;
        padding-left: 7px;
    }

    .api-main-tabs {
        margin-right: -7px;
        margin-left: -7px;
    }

    .mobile-app-bottom-nav span { font-size: 8px; }
}
