/* レスポンシブスタイル */

/* モバイル用フィルターメニュー - デフォルトは非表示 */
.mobile-filter-container {
    display: none;
    position: relative;
}

/* デスクトップ用フィルターボタン - デフォルトは表示 */
.desktop-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* デスクトップサイズ（769px以上）では確実にモバイルメニューを非表示 */
@media (min-width: 769px) {
    .mobile-filter-container {
        display: none !important;
    }
    
    .desktop-filters {
        display: flex !important;
    }
}

.mobile-filter-toggle {
    width: 100%;
    padding: 12px 16px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    color: #333;
}

.mobile-filter-toggle:hover,
.mobile-filter-toggle.active {
    border-color: #667eea;
    background: #f8f9ff;
}

.mobile-filter-toggle i:first-child {
    color: #667eea;
    margin-right: 8px;
}

.mobile-filter-toggle i:last-child {
    transition: transform 0.3s ease;
    color: #888;
}

.mobile-filter-toggle.active i:last-child {
    transform: rotate(180deg);
}

.mobile-filter-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    z-index: 100;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.mobile-filter-menu.show {
    max-height: 300px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.mobile-filter-btn {
    width: 100%;
    padding: 12px 16px;
    background: white;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #333;
    font-size: 0.95rem;
}

.mobile-filter-btn:hover {
    background: #f8f9ff;
    color: #667eea;
}

.mobile-filter-btn.active {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.mobile-filter-btn:last-child {
    border-bottom: none;
}

/* タブレット対応 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .commands-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 15px;
    }
    
    .custom-input-group {
        flex-direction: column;
    }
    
    .custom-input-group input {
        min-width: auto;
    }
    
    /* デスクトップフィルターを非表示、モバイルフィルターを表示 */
    .desktop-filters {
        display: none !important;
    }
    
    .mobile-filter-container {
        display: block !important;
        margin-bottom: 20px;
    }
    
    footer {
        margin: 20px 15px 15px;
        padding: 20px 15px;
    }
    
    footer p:first-child {
        font-size: 1rem;
    }
    
    footer p:last-child {
        font-size: 0.85rem;
    }
    
    /* お問い合わせナビゲーション - モバイル */
    .contact-navigation {
        padding: 20px 15px;
        margin-bottom: 20px;
    }
    
    .contact-cta h2 {
        font-size: 1.3rem;
        margin-bottom: 10px;
    }
    
    .contact-cta p {
        font-size: 0.9rem;
        margin-bottom: 20px;
    }
    
    .contact-btn {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
    
    /* 更新履歴セクション */
    .update-history-section {
        padding: 20px;
        margin-bottom: 25px;
    }
    
    .update-history-section h2 {
        font-size: 1.3rem;
        margin-bottom: 20px;
    }
    
    .update-timeline {
        padding-left: 25px;
    }
    
    .update-item {
        padding-left: 20px;
        margin-bottom: 25px;
    }
    
    .update-content h3 {
        font-size: 1rem;
        margin-bottom: 10px;
    }
    
    .update-content li {
        font-size: 0.9rem;
        padding-left: 18px;
    }
    
    .update-date {
        font-size: 0.85rem;
    }
}

/* iPhone/スマートフォン対応 */
@media (max-width: 480px) {
    .container {
        padding: 10px;
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        touch-action: pan-y;
    }
    
    /* モバイルフィルターのサイズ調整 */
    .mobile-filter-toggle {
        font-size: 0.9rem;
        padding: 10px 14px;
    }
    
    .mobile-filter-btn {
        font-size: 0.9rem;
        padding: 10px 14px;
    }
    
    /* Z-indexの調整（モーダルとの競合を避ける） */
    .mobile-filter-menu {
        z-index: 50;
    }
    
    /* モーダルのZ-index */
    .modal-overlay {
        z-index: 1000;
    }
    
    header {
        padding-top: max(0px, env(safe-area-inset-top));
        margin-bottom: 20px;
    }
    
    header h1 {
        font-size: 1.8rem;
        margin-bottom: 8px;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .header-controls {
        position: relative;
        margin-top: 15px;
        justify-content: center;
    }
    
    .search-section {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .commands-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        margin-bottom: 20px;
    }
    
    .command-card {
        padding: 15px;
    }
    
    .command-title {
        font-size: 1rem;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    
    .command-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .btn-copy,
    .btn-param {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }
    
    .custom-command-section,
    .recent-section {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .custom-command-section h2,
    .recent-section h2 {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }
    
    .custom-command-item,
    .recent-command-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .custom-command-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .recent-command-item .btn-copy {
        align-self: flex-end;
        width: auto;
        min-height: 36px;
    }
    
    /* モーダル調整 */
    .modal {
        width: 95%;
        margin: 10px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 15px;
    }
    
    /* お問い合わせフォーム */
    .contact-section {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .contact-section h2 {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }
    
    .contact-section input,
    .contact-section textarea {
        padding: 14px 12px;
        font-size: 16px; /* iOSのズーム防止 */
    }
    
    .contact-section textarea {
        min-height: 100px;
    }
    
    .contact-section button[type="submit"] {
        width: 100%;
        min-height: 44px;
        justify-content: center;
        align-self: stretch;
    }
    
    /* フッター */
    footer {
        margin: 15px 10px 10px;
        padding: 18px 12px;
        border-radius: 8px;
    }
    
    footer p:first-child {
        font-size: 0.95rem;
        margin-bottom: 6px;
    }
    
    footer p:last-child {
        font-size: 0.8rem;
    }
    
    /* 通知 */
    .notification {
        top: max(10px, env(safe-area-inset-top));
        right: 10px;
        left: 10px;
        transform: translateY(-100%);
    }
    
    .notification.show {
        transform: translateY(0);
    }
}

/* タッチ操作の改善 */
@media (max-width: 480px) {
    /* タッチハイライトの無効化 */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* テキスト選択可能な要素 */
    .command-code,
    .custom-command-code,
    .recent-command-code,
    .command-preview,
    input,
    textarea {
        -webkit-user-select: text;
        user-select: text;
    }
    
    /* ボタンのタッチフィードバック */
    button {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        touch-action: manipulation;
    }
    
    /* スクロール最適化 */
    .commands-grid,
    .custom-commands-list,
    .recent-commands {
        -webkit-overflow-scrolling: touch;
    }
    
    /* アクティブ状態の調整 */
    .command-card:active {
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    }
    
    .btn-copy:active,
    .btn-param:active,
    .btn-primary:active,
    .btn-secondary:active,
    .btn-delete:active {
        transform: scale(0.98);
    }
    
    .filter-btn:active {
        transform: scale(0.95);
    }
    
    /* フォーカス状態の改善 */
    input:focus,
    button:focus {
        outline: 2px solid #667eea;
        outline-offset: 2px;
    }
}

/* iPhone/スマートフォン対応 */
@media (max-width: 480px) {
    /* お問い合わせナビゲーション - 小型モバイル */
    .contact-navigation {
        padding: 15px 10px;
    }
    
    .contact-cta h2 {
        font-size: 1.2rem;
    }
    
    .contact-cta p {
        font-size: 0.85rem;
    }
    
    .contact-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
}

/* iPhone 追加最適化 */
@media (max-width: 480px) {
    /* スクロール性能の改善 */
    body {
        /* スムーズスクロール */
        scroll-behavior: smooth;
        /* バウンススクロールの無効化 */
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch;
        /* タッチイベントの最適化 */
        touch-action: pan-y pinch-zoom;
    }
    
    /* 入力フィールドの改善 */
    input, textarea, select {
        /* iOSでのズーム防止 */
        font-size: 16px !important;
        /* タッチ操作の改善 */
        touch-action: manipulation;
        /* 背景色の固定（iOSの自動変更を防ぐ） */
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* 横向き時の調整 */
    @media (orientation: landscape) {
        .container {
            padding: 10px 15px;
        }
        
        header h1 {
            font-size: 1.6rem;
            margin-bottom: 5px;
        }
        
        header p {
            font-size: 0.9rem;
        }
        
        .search-section {
            padding: 12px;
            margin-bottom: 15px;
        }
        
        .commands-grid {
            gap: 12px;
        }
        
        .command-card {
            padding: 12px;
        }
        
        .modal {
            max-height: 85vh;
        }
    }
    
    /* 通知の位置調整 */
    .notification {
        top: max(15px, env(safe-area-inset-top));
        left: 15px;
        right: 15px;
        transform: translateY(-120%);
        border-radius: 8px;
        padding: 12px 15px;
        font-size: 0.9rem;
        /* 影の調整 */
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        /* Z-indexの調整 */
        z-index: 10000;
    }
    
    .notification.show {
        transform: translateY(0);
        animation: slideInTop 0.3s ease-out;
    }
    
    @keyframes slideInTop {
        from {
            transform: translateY(-120%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    /* フッターの改善 */
    footer {
        margin: 15px 10px max(10px, env(safe-area-inset-bottom));
        padding: 15px 12px max(15px, env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-radius: 10px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    }
    
    /* ナビゲーションアクションの改善 */
    .nav-actions {
        margin-top: 15px;
        display: flex;
        justify-content: center;
    }
    
    .nav-actions .btn-secondary {
        min-height: 44px;
        padding: 10px 20px;
        font-size: 0.9rem;
        border-radius: 22px;
        background: rgba(255, 255, 255, 0.2);
        color: white;
        border: 1px solid rgba(255, 255, 255, 0.3);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    
    .nav-actions .btn-secondary:hover {
        background: rgba(255, 255, 255, 0.3);
        border-color: rgba(255, 255, 255, 0.5);
    }
    
    .nav-actions .btn-secondary:active {
        transform: scale(0.98);
        background: rgba(255, 255, 255, 0.4);
    }
    
    /* ヘッダーコントロールの改善 */
    .header-controls {
        margin-top: 20px;
        gap: 12px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .control-btn {
        min-height: 44px;
        padding: 8px 16px;
        font-size: 0.85rem;
        border-radius: 22px;
        background: rgba(255, 255, 255, 0.2);
        color: white;
        border: 1px solid rgba(255, 255, 255, 0.3);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        display: flex;
        align-items: center;
        gap: 6px;
        transition: all 0.3s ease;
        cursor: pointer;
        /* タッチ操作の改善 */
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    }
    
    .control-btn:hover {
        background: rgba(255, 255, 255, 0.3);
        border-color: rgba(255, 255, 255, 0.5);
        transform: translateY(-1px);
    }
    
    .control-btn:active {
        transform: scale(0.98);
        background: rgba(255, 255, 255, 0.4);
    }
    
    .control-btn i {
        font-size: 1rem;
    }
    
    /* ローディング状態の改善 */
    .btn-copy:disabled,
    .btn-param:disabled,
    .btn-primary:disabled,
    .btn-secondary:disabled {
        opacity: 0.6;
        cursor: not-allowed;
        transform: none !important;
    }
    
    /* スピナーアニメーション */
    .fa-spinner {
        animation: spin 1s linear infinite;
    }
    
    @keyframes spin {
        from { transform: rotate(0deg); }
        to { transform: rotate(360deg); }
    }
    
    /* フォーカス状態の改善 */
    input:focus,
    textarea:focus,
    button:focus,
    select:focus {
        outline: 2px solid #667eea;
        outline-offset: 2px;
    }
    
    /* アクセシビリティの改善 */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
            scroll-behavior: auto !important;
        }
    }
    
    /* 高コントラストモード対応 */
    @media (prefers-contrast: high) {
        .command-card {
            border: 2px solid #333;
        }
        
        .btn-copy,
        .btn-param,
        .btn-primary {
            border: 2px solid currentColor;
        }
        
        .filter-btn {
            border: 2px solid currentColor;
        }
    }
}

/* iPhone Mini / 非常に小さい画面対応 */
@media (max-width: 360px) {
    .container {
        padding: 8px;
    }
    
    header h1 {
        font-size: 1.6rem;
    }
    
    header p {
        font-size: 0.9rem;
    }
    
    .search-section,
    .custom-command-section,
    .recent-section,
    .contact-section {
        padding: 10px;
        margin-bottom: 15px;
    }
    
    .command-card {
        padding: 10px;
    }
    
    .command-title {
        font-size: 0.9rem;
    }
    
    .command-description {
        font-size: 0.75rem;
    }
    
    .command-code {
        font-size: 0.7rem;
        padding: 6px 8px;
    }
    
    .btn-copy,
    .btn-param,
    .btn-primary,
    .btn-secondary {
        min-height: 36px;
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    .control-btn {
        min-height: 36px;
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    
    .filter-btn {
        min-height: 36px;
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    .mobile-filter-toggle {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .mobile-filter-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* iPhone Safari背景修正 */
@media (max-width: 480px) {
    /* iPhone Safari固有の背景問題を修正 */
    html {
        background-color: #667eea !important; /* フォールバック色を強制 */
        background-image: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        background-attachment: scroll !important;
        background-repeat: no-repeat !important;
        background-size: 100% 100% !important;
        background-position: center center !important;
        min-height: 100% !important;
        height: 100% !important;
    }
    
    body {
        background-color: #667eea !important; /* フォールバック色を強制 */
        background-image: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        background-attachment: scroll !important; /* iOSでfixedが効かない場合があるためscrollに変更 */
        background-repeat: no-repeat !important;
        background-size: 100% 100% !important; /* サイズを明示的に指定 */
        background-position: center center !important;
        /* Webkit専用プレフィックス */
        -webkit-background-size: 100% 100% !important;
        /* 最小高さを確保 */
        min-height: 100vh !important;
        min-height: -webkit-fill-available !important; /* iOSのviewport問題対応 */
        /* より強い指定 */
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        /* 追加のiOS Safari対策 */
        -webkit-background-clip: border-box !important;
        background-clip: border-box !important;
    }
    
    /* コンテナの背景透過を確実にする */
    .container {
        background: transparent !important;
        background-color: transparent !important;
    }
    
    /* セクションの背景を半透明に調整 */
    .search-section,
    .custom-command-section,
    .recent-section,
    .contact-section,
    .contact-navigation,
    .update-history-section {
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }
}
