/* استایل‌های مخصوص iPad — اندازه‌های کوچک‌تر برای نمایش راحت‌تر */

/* iPad عمودی و افقی کوچک (۷۶۸–۱۰۲۴px) */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    .sidebar {
        width: 260px;
        max-height: 100vh;
        max-height: 100dvh;
    }

    .sidebar .search {
        padding: 10px 12px;
    }

    .sidebar .search input[type="text"] {
        padding: 8px 10px;
        font-size: 13px;
    }

    .table-selector {
        padding: 10px 12px;
    }

    .table-selector label {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .table-buttons {
        gap: 6px;
    }

    .table-btn,
    .global-search-lib-btn,
    .global-search-btn {
        min-height: 40px;
        padding: 8px 12px;
        font-size: 13px;
    }

    .books-header {
        padding: 10px 12px;
    }

    .books-header h2 {
        font-size: 14px;
    }

    .global-search-trigger-btn,
    .sidebar-toggle-btn {
        min-height: 40px;
        min-width: 40px;
        font-size: 15px;
    }

    .list li {
        padding: 10px 12px;
        font-size: 13px;
    }

    .sort-controls {
        padding: 8px 12px;
    }

    .sort-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .content-wrapper {
        flex-direction: row;
        gap: 12px;
        padding: 10px;
    }

    .content {
        padding: 14px;
    }

    .toc-sidebar {
        width: 240px;
        min-width: 220px;
        height: calc(100vh - 20px);
        max-height: calc(100vh - 20px);
        position: sticky;
        top: 10px;
    }

    .toc-header {
        padding: 8px 10px;
    }

    .toc-header h3 {
        font-size: 14px;
    }

    .toc-item {
        font-size: 13px;
    }

    .toc-level-1 .toc-item-content {
        font-size: 14px;
        padding: 8px 10px;
    }

    .toc-level-2 .toc-item-content {
        font-size: 13px;
        padding: 6px 10px 6px 18px;
    }

    .toc-toggle {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }

    .toc-toggle-spacer {
        width: 24px;
    }

    .search-nav-btn,
    .global-search-trigger-btn {
        min-height: 40px;
        min-width: 40px;
        padding: 6px 10px;
        font-size: 13px;
    }

    .book-nav-controls {
        flex-wrap: wrap;
        gap: 6px;
    }

    .book-nav-controls .search-nav-btn {
        min-width: 90px;
        min-height: 40px;
        font-size: 13px;
    }

    .scroll-progress-wrapper {
        margin-top: 8px;
        padding: 6px 10px;
    }

    .scroll-progress-bar {
        height: 8px;
    }

    .scroll-progress-text {
        min-width: 42px;
        font-size: 12px;
        padding: 4px 8px;
    }

    .book-text-wrapper {
        padding: 12px 16px;
    }

    .book-content {
        font-size: 17px !important;
        line-height: 2.1 !important;
        letter-spacing: 0.3px !important;
        word-spacing: 1px !important;
    }

    .book-content p {
        margin-bottom: 1.4em !important;
        text-indent: 1.5em !important;
    }

    .book-content h1 {
        font-size: 1.6em;
    }

    .book-content h2 {
        font-size: 1.4em;
    }

    .book-content h3 {
        font-size: 1.25em;
    }

    /* نوار ابزار شناور — متناسب با iPad (۷۶۸–۱۰۲۴) */
    .floating-toolbar {
        right: 14px;
        top: 50%;
        transform: translateY(-50%);
        padding: 10px 7px;
        border-radius: 14px;
        gap: 8px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        border: 1px solid rgba(0, 0, 0, 0.06);
    }

    .floating-toolbar:hover {
        transform: translateY(-50%) scale(1.02);
    }

    .toolbar-group {
        gap: 6px;
    }

    .toolbar-divider {
        margin: 4px 0;
        height: 1px;
    }

    .toolbar-btn {
        width: 42px;
        height: 42px;
        min-width: 42px;
        min-height: 42px;
        font-size: 16px;
        border-radius: 10px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .toolbar-btn::after {
        right: 48px;
        padding: 5px 10px;
        font-size: 12px;
        border-radius: 6px;
    }

    .toolbar-btn::before {
        right: 44px;
        border-width: 5px 0 5px 5px;
    }

    .toolbar-close-btn {
        width: 24px;
        height: 24px;
        top: 5px;
        right: 5px;
        font-size: 18px;
    }

    .floating-toolbar-body {
        padding-top: 24px;
    }

    .floating-toolbar.collapsed .toolbar-open-btn {
        width: 42px;
        height: 42px;
        font-size: 20px;
    }

    .global-search-popup-content {
        width: 88%;
        max-width: 560px;
    }

    .global-search-popup-header {
        padding: 12px 16px;
    }

    .global-search-popup-header h3 {
        font-size: 15px;
    }

    .global-search-popup-body {
        padding: 12px 16px;
    }

    .global-search-library-selector {
        padding: 10px 12px;
        margin-bottom: 12px;
    }

    .global-search-input-wrapper {
        gap: 8px;
        margin-bottom: 12px;
    }

    .global-search-input {
        padding: 10px 12px;
        font-size: 14px;
    }

    .global-search-btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .global-search-results {
        max-height: 45vh;
    }

    .global-search-book-header {
        padding: 10px 12px;
        font-size: 13px;
    }

    .global-search-snippet {
        padding: 8px 10px;
        font-size: 13px;
    }

    .toc-reopen-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .sidebar-reopen-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    /* اسکرول‌بار باریک برای iPad */
    .content::-webkit-scrollbar {
        width: 10px;
    }

    .content::-webkit-scrollbar-thumb {
        background: #b0b0b0;
        border-radius: 5px;
        border: 2px solid #f5f5f5;
        min-height: 40px;
    }

    .content::-webkit-scrollbar-track {
        background: #f5f5f5;
        border-radius: 5px;
    }

    .content {
        scrollbar-width: thin;
        scrollbar-color: #b0b0b0 #f5f5f5;
    }

    .toc-content::-webkit-scrollbar,
    .sidebar::-webkit-scrollbar {
        width: 8px;
    }
}

/* iPad در حالت landscape */
@media screen and (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) {
    .toc-sidebar {
        width: 260px;
        min-width: 240px;
    }

    .sidebar {
        width: 280px;
    }

    .global-search-popup-content {
        max-width: 640px;
    }

    .content {
        padding: 16px;
    }

    /* نوار ابزار شناور در landscape — کمی بزرگ‌تر و متناسب */
    .floating-toolbar {
        right: 16px;
        padding: 11px 8px;
        border-radius: 15px;
        gap: 8px;
    }

    .toolbar-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        font-size: 17px;
        border-radius: 11px;
    }

    .toolbar-btn::after {
        right: 52px;
        font-size: 12px;
    }

    .toolbar-btn::before {
        right: 48px;
    }

    .content::-webkit-scrollbar {
        width: 10px;
    }

    .content::-webkit-scrollbar-thumb {
        background: #b0b0b0;
        border-radius: 5px;
        border: 2px solid #f5f5f5;
        min-height: 40px;
    }

    .content::-webkit-scrollbar-track {
        background: #f5f5f5;
        border-radius: 5px;
    }

    .content {
        scrollbar-width: thin;
        scrollbar-color: #b0b0b0 #f5f5f5;
    }
}
