/* toolbar-menu.css - ツールバーメニューのスタイル */

/* ツールバーコンテナ */
.toolbar-menu {
    background-color: #334155;
    border-bottom: 1px solid #1e293b;
    padding: 0;
    position: sticky;
    top: 60px; /* ヘッダーの下に配置 */
    z-index: 100; /* プラン情報表示(z-index:99)より上に配置 */
}

.toolbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    gap: 4px;
}

/* ドロップダウンコンテナ */
.toolbar-dropdown {
    position: relative;
}

/* ツールバーボタン */
.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.toolbar-btn:hover {
    background-color: #475569;
    color: #ffffff;
}

.toolbar-btn.active {
    background-color: var(--color-primary);
    color: #ffffff;
}

.toolbar-btn i:first-child {
    font-size: 14px;
}

.toolbar-btn .fa-caret-down {
    font-size: 10px;
    margin-left: 2px;
    transition: transform 0.2s ease;
}

.toolbar-btn.active .fa-caret-down {
    transform: rotate(180deg);
}

/* ドロップダウンコンテンツ */
.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    padding: 6px 0;
    z-index: 10000; /* プラン情報表示より上に */
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.dropdown-content.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* ドロップダウンアイテム */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: #334155;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.dropdown-item:hover {
    background-color: #f1f5f9;
}

.dropdown-item:disabled {
    color: #94a3b8;
    cursor: not-allowed;
}

.dropdown-item:disabled:hover {
    background-color: transparent;
}

.dropdown-item i {
    width: 18px;
    text-align: center;
    color: #64748b;
}

.dropdown-item:hover i {
    color: var(--color-info-dark);
}

.dropdown-item:disabled i {
    color: #cbd5e1;
}

/* サブメニュー */
.dropdown-submenu {
    position: relative;
}

.dropdown-item.has-submenu {
    justify-content: flex-start;
}

.submenu-arrow {
    margin-left: auto;
    font-size: 10px;
}

.submenu-content {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 160px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    padding: 6px 0;
    z-index: 10001; /* ドロップダウンより上に */
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.dropdown-submenu:hover .submenu-content {
    display: block;
    opacity: 1;
    transform: translateX(0);
}

/* 区切り線 */
.dropdown-divider {
    height: 1px;
    background-color: #e2e8f0;
    margin: 6px 0;
}

/* モバイル対応 */
@media screen and (max-width: 640px) {
    .toolbar-menu {
        top: 56px; /* モバイルヘッダーに合わせる */
    }

    .toolbar-container {
        padding: 0 10px;
        gap: 2px;
    }

    .toolbar-btn {
        padding: 10px 14px;
        font-size: 14px;
    }

    /* モバイルではアイコンを少し大きく表示 */
    .toolbar-btn i:first-child {
        font-size: 18px;
    }

    /* テキストも表示する（メニュー項目が少ないので収まる） */
    .toolbar-btn span {
        display: inline;
    }

    .toolbar-btn .fa-caret-down {
        display: none;
    }

    .dropdown-content {
        min-width: 180px;
    }

    /* サブメニューをモバイルでは下に展開 */
    .submenu-content {
        left: 0;
        top: 100%;
        margin-top: -6px;
    }
}

/* 非常に小さな画面 */
@media screen and (max-width: 480px) {
    .toolbar-btn {
        padding: 8px 10px;
        font-size: 13px;
    }

    .toolbar-btn i:first-child {
        font-size: 16px;
    }

    .dropdown-content {
        min-width: 160px;
        left: -10px;
    }

    .dropdown-item {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* ソートドロップダウンのスタイル */
.sort-select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-white);
    color: var(--color-text-primary);
    font-size: 14px;
    cursor: pointer;
    min-width: 150px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sort-select:hover {
    border-color: #94a3b8;
}

.sort-select:focus {
    outline: none;
    border-color: var(--color-info-dark);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.sort-select:disabled {
    background-color: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}

.sort-direction-select {
    min-width: 100px;
}

/* モバイル対応 */
@media screen and (max-width: 640px) {
    .sort-select {
        min-width: 120px;
        font-size: 13px;
        padding: 6px 10px;
    }

    .sort-direction-select {
        min-width: 80px;
    }
}

/* ショートカットヒント */
.shortcut-hint {
    margin-left: auto;
    font-size: 11px;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 3px;
}

/* スマホ向けフローティングUndo/Redoボタン */
.mobile-undo-redo-buttons {
    display: none; /* デスクトップでは非表示 */
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    flex-direction: column;
    gap: 10px;
}

.mobile-undo-btn,
.mobile-redo-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: var(--gradient-brand);
    color: white;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-undo-btn:hover:not(:disabled),
.mobile-redo-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.mobile-undo-btn:disabled,
.mobile-redo-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    box-shadow: none;
}

.mobile-undo-btn:active:not(:disabled),
.mobile-redo-btn:active:not(:disabled) {
    transform: scale(0.95);
}

/* タッチデバイスでのみフローティングボタンを表示 */
@media (pointer: coarse) {
    .mobile-undo-redo-buttons {
        display: flex;
    }
}

/* スマホサイズでもフローティングボタンを表示 */
@media screen and (max-width: 768px) {
    .mobile-undo-redo-buttons {
        display: flex;
    }

    /* ショートカットヒントはスマホでは非表示 */
    .shortcut-hint {
        display: none;
    }
}
