/* モバイル専用スタイル */

/* デスクトップでモバイル専用要素を非表示 */
.mobile-sidebar-toggle {
    display: none;
}

/* タブレット・スマートフォン対応 (768px以下) */
@media (max-width: 768px) {
    /* モバイル専用サイドバートグルボタンを表示 */
    .mobile-sidebar-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background-color: var(--primary-color) !important;
        color: white !important;
        border: none !important;
        position: absolute !important;
        left: 0.5rem !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        z-index: 100 !important;
    }

    .mobile-sidebar-toggle:hover {
        background-color: var(--primary-hover) !important;
    }
    /* 不要な要素を非表示 */
    #createSharedDocBtn,
    #leaveSharedBtn,
    #desktopPromoBanner,
    .desktop-sidebar-toggle {
        display: none !important;
    }

    /* サイドバーレイアウト */
    .main-content.sidebar-collapsed .sidebar {
        width: 0;
    }

    .sidebar {
        width: 280px;
        position: absolute;
        left: -280px;
        height: calc(100vh - 70px);
        z-index: 50;
        transition: left 0.3s ease;
    }

    .sidebar.show {
        left: 0;
    }

    /* ヘッダー調整 */
    .header-content {
        padding: 0.5rem 0.75rem 0.5rem 3rem; /* 左側にボタンのスペースを確保 */
        flex-wrap: wrap;
        gap: 0.5rem;
        position: relative;
    }

    .logo {
        font-size: 1rem;
        order: 1;
        flex: 1;
    }

    .header-actions {
        order: 2;
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
        justify-content: flex-end;
    }

    /* ボタンサイズ調整 */
    .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
        min-height: 32px;
    }

    .btn-icon {
        padding: 0.375rem;
        min-width: 32px;
        min-height: 32px;
    }

    /* エディターエリア */
    .editor-header {
        padding: 0.5rem 0.75rem;
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }

    .note-title-section {
        margin-bottom: 0.25rem;
        gap: 0.5rem;
    }

    /* モバイルでは検索入力欄を非表示 */
    .note-title-section .search-input-container {
        display: none !important;
    }

    /* モバイルでは検索ボタンを表示 */
    #searchBtn {
        display: inline-flex !important;
    }


    .editor-tools {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
        justify-content: center;
        align-items: center;
    }

    .editor-tools .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
        min-height: 28px;
    }

    .editor-tools .btn-small {
        padding: 0.2rem 0.4rem;
        font-size: 0.65rem;
        min-height: 26px;
    }

    .save-status {
        font-size: 0.7rem;
        order: -1;
        margin-bottom: 0.25rem;
    }

    /* コンテンツエリア */
    .tree-container {
        padding: 0.5rem;
    }

    /* その他 */
    .context-menu {
        min-width: 180px;
    }

    .notification {
        top: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
        max-width: none;
    }

    /* デスクトップとモバイルメッセージ切り替え */
    .desktop-message {
        display: none;
    }

    .mobile-message {
        display: block;
    }
}

/* 小画面デバイス対応 (480px以下) */
@media (max-width: 480px) {
    /* ヘッダーの更なる縮小 */
    .header-content {
        padding: 0.4rem 0.5rem;
    }

    .header-actions {
        gap: 0.2rem;
    }

    /* ボタンテキストを非表示 */
    .btn span {
        display: none;
    }

    /* 小画面でも検索ボタンを確実に表示 */
    #searchBtn {
        display: inline-flex !important;
    }

    .logo span {
        font-size: 0.9rem;
    }

    /* ボタンサイズをさらに縮小 */
    .btn {
        padding: 0.3rem;
        min-width: 28px;
        min-height: 28px;
        font-size: 0.8rem;
    }

    .btn-icon {
        padding: 0.3rem;
        min-width: 28px;
        min-height: 28px;
    }

    /* サイドバーを全幅に */
    .sidebar {
        width: 100%;
        left: -100%;
    }

    /* エディターツールを更に小さく */
    .editor-tools .btn {
        padding: 0.2rem 0.3rem;
        font-size: 0.65rem;
        min-height: 24px;
        min-width: 24px;
    }

    .editor-tools .btn-small {
        padding: 0.15rem 0.25rem;
        font-size: 0.6rem;
        min-height: 22px;
        min-width: 22px;
    }

    /* ノートタイトルを小さく */
    .note-title {
        font-size: 0.9rem;
        padding: 0.4rem;
    }

    /* プレースホルダー調整 */
    .editor-placeholder {
        padding: 1rem;
    }

    .editor-placeholder i {
        font-size: 2.5rem;
    }

    .editor-placeholder h3 {
        font-size: 1.25rem;
    }
}

/* タッチデバイス専用の調整 */
@media (hover: none) and (pointer: coarse) {
    /* タッチターゲットサイズを確保 */
    .btn,
    .tree-item-content,
    .note-item {
        min-height: 44px;
    }

    /* ホバー効果を無効化 */
    .btn:hover,
    .tree-item-content:hover,
    .note-item:hover {
        transform: none;
    }

    /* タッチフィードバックを強化 */
    .touch-feedback:active {
        transform: scale(0.95);
        transition: transform 0.1s;
    }
}